Microsoft Touch Mouse, Visual Studio (2012) and scrolling

My Microsoft Touch Mouse stopped scrolling in Visual Studio on my Windows 8 machine some time ago. Because this kills productivity, I wanted to fix the problem. After trying some things I found that the problem only occurred when I ran Visual Studio as Administrator. Searching a bit further I found this bug to be added to Microsoft Connect. I found a workaround for the problem:

  • Go to the location where you have Microsoft Mouse and Keyboard Center installed
  • Open up the properties of ipoint.exe
  • Set it to Run as Administrator
  • Kill and restart ipoint.exe (or restart the machine)
  • Welcome back scrolling in Visual Studio…!

Hope this helps

Unable to access the IIS metabase

The Web Application Project SomeWebProject is configured to use IIS.  Unable to access the IIS metabase. You do not have sufficient privilege to access IIS web sites on your machine.I opened a solution in Visual Studio 2012 on my laptop running Windows 8, when I was presented with the error “The Web Application Project SomeWebProject is configured to use IIS.  Unable to access the IIS metabase. You do not have sufficient privilege to access IIS web sites on your machine.” The user I was logged in with was a local administrator and was able to open up and use IIS Manager, but still I was presented with this error. The solution to this is simple: start your Visual Studio with ‘Run as Administrator’. You can do this by right clicking the shortcut and selecting ‘Run as Administrator’.

TIP:
To always have your Visual Studio open with ‘Run as Administrator’, please follow these steps:
– right click the shortcut you are used to use
– bring up its properties
– click ‘Advanced…’ on the ‘Shortcut’ tab
– check the box ‘Run as administrator’ (see image below)
– close the windows with ‘OK’

Somehow I felt like this was default behavior on my Win7 VS2010 install, but it might be I set up the shortcut for it there too…

Ajax Control Toolkit Calendar doesn’t close when clicking outside the calendar

Just a quick one: if you have a textbox with a Calendar (extender) from the Ajax Control Toolkit and an associated PopupButtonID which is an image, the calendar won’t close when you click outside the popup. Use an input type=”image”or an ImageButton to solve this problem.

Hope this helps.

Documents.Open returns null, running Word automation under ASP.NET on x64

When building an ASPapplication that generates Word documents,  it was working fine on the local machine. A windows XP installation with Office 2007. When we deployed it to windows 2008 (64 bit) and Word 2007 we saw that Documents.Open returned null. Other than this, there are no exceptions.

The code that returned the error (simplified):

Application app = new Application();
Document doc = app.Documents.Open(ref name);

As it turns out, a 64 bit system stores temporary files in “C:WindowsSysWOW64configsystemprofileDesktop” folder.

The solution: create a new directory called “Desktop” inside “C:WindowsSysWOW64configsystemprofile”

Hope this helps.

Unhandled exception installing SQL Server 2008 R2 on a Windows XP / Windows 7 machine

System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for userSettings/Microsoft.SqlServer.Configuration.LandingPage.Properties.Settings: Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified. (C:Documents and SettingsBoschRLocal SettingsApplication DataMicrosoft_CorporationLandingPage.exe_StrongName_ryspccglaxmt4nhllj5z3thycltsvyyx10.0.0.0user.config line 5) ---> System.IO.FileNotFoundException: Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.When installing SQL Server 2008 R2 on a Windows XP (or, according to the comments, Windows 7) development machine that has been around for quite some time, I got an error stating an unhandled exception occured in the application (see image). The error showed up directly upon startup and read:

An error occurred creating the configuration section handler for userSettings/Microsoft.SqlServer.Configuration.LandingPage.Properties.Settings: Could not load file or assembly ‘System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’ or one of its dependencies.

Repairing the .NET 4.0 framework didn’t solve the issue. Neither did removing all SQL stuff through ‘Add or Remove Programs’. Looking into the error a bit further…

 The system cannot find the file specified. (C:Documents and Settings_USERNAME_Local SettingsApplication DataMicrosoft_CorporationLandingPage.exe_StrongName_ryspccglaxmt4nhllj5z3thycltsvyyx10.0.0.0user.config line 5) —> System.IO.FileNotFoundException: Could not load file or assembly ‘System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’ or one of its dependencies. The system cannot find the file specified.

 So the problem probably wasn’t that System.dll couldn’t be found, but some user.config file for the landingpage executable. The solution is as simple as it is radical: remove the entire (temporary) folder ‘C:Documents and Settings_USERNAME_Local SettingsApplication DataMicrosoft_Corporation’ (where USERNAME_ is, of course, the current username). After this the setup should start up without any problems.

Error installing the Windows Azure AppFabric Tools for Visual Studio (CTP)

Windows Server AppFabric is installed and is not compatible with this release of Windows Azure AppFabric Developer Tools for Microsoft Visual Studio 2010 - June 2011 CTP. Please uninstall Windows Server AppFabric and rerun this setup if you want to install Windows Azure AppFabric Developer Tools for Microsoft Visual Studio 2010 - June 2011 CTP.When installing the Windows Azure AppFabric Tools for Visual Studio (found here), you might get the error message shown on the right, stating that Windows Server AppFabric is installed and that it is not compatible with this release of Windows Azure AppFabric Developer Tools for Microsoft Visual Studio 2010 – June 2011 CTP. It asks to uninstall Windows Server AppFabric and rerun this setup if you want to install Windows Azure AppFabric Developer Tools for Microsoft Visual Studio 2010 – June 2011 CTP.

When looking for the install of ‘Windows Server AppFabric’ to remove it through ‘Uninstall a program’ you won’t find this item in the list of installed programs. This might feel as a big problem heading your way…

Solution
This is, however, only a small problem on your way to Azure AppFabric development. Go to your list of installed programs and click ‘View installed updates’. Under Windows, you will find the update ‘Windows Server AppFabric (KB970622)’. Uninstall the update, restart your machine and try installing the Windows Azure AppFabric Tools for Visual Studio again…

Enjoy!

HowTo: Save a file from Silverlight using the SaveFileDialog

Saving a file from Silverlight using the SaveFileDialog, added in Silverlight 3, is easy. If you’re used to desktop development however, you might find yourself getting a SecurityException with the message ‘File operation not permitted. Access to path ‘xxx’ is denied.’. Here’s why:

In desktop development, you’re used to getting a filename from a SaveFileDialog. Next, you start doing whatever you need to be doing to the file, based on the filename. This would look something like this:

SaveFileDialog saveFileDialog = new SaveFileDialog();

if (saveFileDialog.ShowDialog() == true)
{
    StreamWriter streamWriter = new StreamWriter(saveFileDialog.SafeFileName);
    streamWriter.Write("Follow me on twitter: @rickvdbosch");
    streamWriter.Flush();
    streamWriter.Close();
}

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

This results in the SecurityException. First time I saw the property, I genuinely thought it said SaveFileName. But, as you can see, it says SafeFileName. It is named safe, because the returned file name has all file path information removed for security purposes.

In Silverlight, if you want the above functionality, it should look something like this:

SaveFileDialog saveFileDialog = new SaveFileDialog();

if (saveFileDialog.ShowDialog() == true)
{
    StreamWriter streamWriter = new StreamWriter(saveFileDialog.OpenFile());
    streamWriter.WriteLine("Follow me on twitter: @rickvdbosch");
    streamWriter.Flush();
    streamWriter.Close();
}

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }The OpenFile method opens the file specified by the SafeFileName returning a Stream, giving you the opportunity to save whatever you want to save over there.

Hope this helps.

On a side note: the ‘== true’ part in the if condition is needed in this case. Because the ShowDialog method returns a nullable boolean it is not enough to use saveFileDiaolog.ShowDialog() in the condition. Just so you know… :)

‘Cannot find entry to delete’ deleting files from a Zip with (SL) SharpZipLib

For a project I’ll probably dedicate a post on this blog to in the future, I needed a ZIP library for Silverlight. After asking around on twitter (@rickvdbosch) I was pointed towards the SharpZipLib port on Codeplex, found on http://slsharpziplib.codeplex.com.

Basically what I wanted to do was replace a file inside the ZIP file with my version of that file. The file was located in a specific folder inside the ZIP and could be found by either iterating through the ZipEntries in the ZIP, or by getting it based on its name. But deleting the file gave me a ZipException with the error message ‘Cannot find entry to delete’. When I added a file myself, it could be deleted just fine, but the ZIP just did not want the existing file to be removed.

After searching around on some forums, I found there was a new development version of SharpZipLib which might solve the problem. But that was the full version, not the Silverlight port. So I searched around some more and found something about subfolders.

As it turns out, and existing file can be deleted when it is located in the root of the ZIP. Apparently there’s some bug keeping you from deleting files in subfolders. Anyhow, moving the file I need updated to the root of the ZIP solved my problem for me (for now), so I can continue my project. If and when slsharpziplib is updated in the future, I’ll have a look if they solved this in the port too…

Hope this helps.

Using Crystal Reports in ASP.NET on a 64 bit machine

The above scenario gave me the well-known could not load file or assembly error message. The assembly that couldn’t be found was  ‘log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304’. Or one of its dependencies of course… The situation in which I was getting this error message:

  • using the CrystalReportViewer in an ASP.NET application
  • having the ASP.NET application hosted in IIS (the error did not occur on the ASP.NET Development Server)
  • running on a 64 bit machine

Log4net was available in the GAC, with the exact version and PublicKeyToken stated in the error message. So that couldn’t be the problem. Or could it…? Having a second (and closer) look at the log4net assembly in the GAC one thing stood out.
log4net-x86

The Processor Architecture for the log4net assembly is set to x86. That means it can’t be loaded by IIS, which is x64 on this machine. OK, so now we know what’s wrong. Next: how to solve this?

Solution
I tried several things to get my (x64) IIS, Crystal Reports and log4net to get to play together nicely. Things that did not help to get this problem fixed included removing log4net from the assemblies section of the web.config, kicking my machine around the office and trying to recompile log4net for the x64 architecture.

As far as I have been able to find out, these two steps will get it working:

  1. Enable 32 bit ASP.NET IIS integration
    Open a command prompt, go to the non x64 framework folder of your choice (for instance C:WindowsMicrosoft.NETFrameworkv4.0.30319) and execute “aspnet_regiis –enable –i”
  2. Enable 32 bit apps for 64 bit IIS
    Open a command prompt and execute “cscript.exe %SystemDrive%inetpubAdminScriptsadsutil.vbs set W3SVC/AppPools/Enable32BitAppOnWin64 true
    If you do not have the admin scripts installed, install the from the ‘Turn Windows features on or off’ option in your Control Panel. The scripts are located under Internet Information Services – Web Management Tools – IIS 6 Management Compatibility – IIS 6 Scripting Tools.

I’m not sure of any negative side-effects at this point. If I run into any in the future I’ll let you know. For now my application is working like a charm!

Hope this helps.

By |January 5th, 2011|.Net, Error, x64|2 Comments

Little-heard-of ASP.NET feature: app_offline.htm

Although the feature has been around since ASP.NET 2.0, I still meet people that don’t know and/or use app_offline.htm. Do you know (and use) the feature…?

When working on an ASP.NET web application, you should notify your visitors in a decent way that your application is down. There’s a nice default feature available for these purposes since ASP.NET 2.0. Somehow, however, this feature is not very well known and rarely used. The “App_Offline.htm” feature in ASP.NET 2.0 provides an easy way to bring down an ASP.NET application while you make changes to it. This feature kicks in as soon as you place a file called app_offline.htm in the root of the application. When ASP.NET detects the file, it will shut-down the app-domain for the application and won’t restart it for requests. The app_offline.htm file will be sent as the response to all new dynamic requests for the application. When you’re done updating the site, just delete or rename the file and your site it will come back online.

Taken from (or actually inspired on) this blog post of Scott Guthrie:

Keep an eye on a feature of IE6(+) called “Show Friendly Http Errors”. This can be configured in the Tools->Internet Options->Advanced tab within IE, and is on by default with IE6. With this setting turned on, when a server returns a non HTTP-200 status code with less than 512 bytes of content, IE will not show the returned HTML and instead substitutes its own generic status code message.

If you use the app_offline.htm feature, make sure you have at least 512 bytes of content within it to make sure that your HTML shows up to your users instead of IE’s friendly status message. If you don’t want to have a lot of text show-up on the page, one trick you can use is to just add an html client-side comment with some bogus content to push it over 512 bytes. For example:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml” >

<head>

    <title>Site Under Construction</title>

</head>

<body>

    <h1>Under Construction</h1>

 

    <h2>We’re currently working on our site…</h2>

   

<!–       

    Adding additional hidden content so that IE Friendly Errors don’t prevent

    this message from displaying (note: it will show a “friendly” 404

    error if the content isn’t of a certain size).

   

    <h2>Gone to Florida for the sun…</h2> 

    <h2>Gone to Florida for the sun…</h2> 

    <h2>Gone to Florida for the sun…</h2> 

    <h2>Gone to Florida for the sun…</h2> 

    <h2>Gone to Florida for the sun…</h2> 

    <h2>Gone to Florida for the sun…</h2> 

    <h2>Gone to Florida for the sun…</h2> 

    <h2>Gone to Florida for the sun…</h2> 

    <h2>Gone to Florida for the sun…</h2> 

    <h2>Gone to Florida for the sun…</h2> 

    <h2>Gone to Florida for the sun…</h2> 

    <h2>Gone to Florida for the sun…</h2> 

    <h2>Gone to Florida for the sun…</h2>     

–>

</body>

</html>

Hope this helps