COM references in Visual Studio and RegSvr32

I was trying to add a new COM DLL to my VS2010 project but it kept giving me the following error message:

A reference to the “….dll” could not be added.Please make sure that the file is accessible and that it is a valid assembly or COM component

Then I realised I hadn’t registered my self-registering assembly on my machine as this was a new machine and the first time I had used this project. Since I had my VS Command Prompt open I ran RegSvr32 on the assembly and waited for the usual message. Instead it threw me an error and I was left to try and find out what was causing the problem. As it turns out the solution was relatively simple. I needed to run my command prompt as the administrator to get RegSvr32 to work as I am using a Windows 7 OS. Now my COM DLL is registered and listed in the COM tab of the Visual Studio Add Reference dialog.

“just because your favorite technology isn’t mentioned in a keynote doesn’t mean it’s dead.”

I am a big fan of Silverlight, its just so much fun to develop with. However, time and tide wait for no man so I am glad MS has updated support for HTML5. I am sure I will get round to learning more about it soon…

IIS (Express) 7.5, Hosts file and Authentication

I have been using IIS Express to do some of my recent development instead of using the ASP.NET Development Server so that I could use the additional functionality within IIS. (Personally, I hate developing with the ASP.NET Development server but I am having to develop on XP at the moment and IIS 5.1 is not much better. Getting IIS Express has been a real bonus.). I had configured my IIS site originally with a localhost address and Visual Studio debugging worked fine. Unfortunately, Fiddler doesn’t like monitoring localhost addresses so I created a new entry in my Hosts file to use localhost.

This created my second issue. When I tried to run my app within VS  I got the ‘Unable to start debugging on the Web server’ error, IISExpress was reporting 401 errors and all because of the entry in the Hosts file. So after the usual search to try and find similar problems I came across this MSDN KB article. I actually used Method 2 in the article and I didn’t need to reboot my machine, just restart my IISExpress instance. This solved my problem as Visual Studio was then happy to go through the authentication process and Fiddler was capturing my Requests/Responses.

IIS Express 7.5 Improves ASP.NET Development

If you suffer the pain of using the ASP.NET Development Server (Cassini) and would like an alternative take a look at this post. The full download is available here.

VS 2010 – Discovering web services in your solution

In order to use the “Discover services in solution” functionality, the service projects must be based on one of the WCF project templates.

If you want to alter your existing project(s) so that they will be identified as projects containing WCF service(s), do the following:

* Right-click on the project in the Solution Explorer, and select Unload project
* Right-click the project again (this time the node will end in (unavailable) ) and choose Edit xxxxx.csproj
* In the first section, add the following line:
{3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
* Save and close the file
* Reload the project by right-clicking it again and choose Reload.

You should then be able to use the “Discover services in solution” functionality.

IE Silverlight vanishing trick!

Not really sure what caused this to happen?
 

I had just configured the VS 2008 development environment on a machine I dont normally use to use the November 2009 version of the Silverlight Toolkit. Having created a new C# Silverlight Navigation Application and put together some basic code I hit F5 and waited for my RIA to fire up so that I could debug it. What I was presented with was dialog box with the error message – ‘Unable to start debugging. Cannot locate Microsoft Internet Explorer.

I hadn’t changed any of my browers settings so I made sure that IE was set as the default browser, I checked that I could open up IE and do some general surfing and I even made sure that the Browse With… worked from within VS. Everything was OK except my ability to run from F5. A few minutes of research pointed me to a (translated) page which highlighted the problem and potential solution.

Navigating to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths I found that the iexplore.exe key was missing. So here’s what I did:

  1. Added the iexplore.exe key to the  registry.
  2. Changed the (Default) REG_SZ value to C:\Program Files\Internet Explorer\iexplore.exe
  3. Added a new REG_SZ value called Path and set it to C:\Program Files\Internet Explorer
  4. Restarted my Visual Studio.

After making these changes, opening my project and hitting F5 it was working again. I have no idea what caused the Key to be removed in the first place but I can only think it was the Silverlight Toolkit installation process that did it???

The virtual path ‘/App_Resources/dev/mycontrol.ascx’ maps to another application which is not allowed

Getting to the root of the problem
 

I had been trying to set up a development environment for Visual Studio so that instead of using the in-built Development Server (Cassini) I could use IIS. Since I had to develop on a Windows XP machine my first problem is that I could not create more that one Web Site under IIS 5.1 so I had to resort to using Virtual Directories for the applications (A Web app and a WCF app). This differed from the live setup where each was configured under its own web site and this is where my problems started. When I fired up the web application I was greeted with this error – The virtual path ‘/App_Resources/dev/mycontrol.ascx’ maps to another application which is not allowed.

The web application used the concept of loading controls from embedded resources using the LoadControl() method and this was causing the error. In the live environment the application is always at the root for the website because of the deployment configuration, however in my scenario the web app was located in a virtual directory off the root web site. The issue occurs because the virtual path ‘/App_Resources/’ assumes that it is at the web site root rather than the application root. To solve the problem I just need to add a tilde (~) to the front of the virtual path in the managed code so it became ‘~/App_Resources/dev/mycontrol.ascx’. I also found instance in the JavaScript code where this situation occurred but this time we just need to use the dot notation to indicate the root folder. The virtual path in the script became ‘./App_Resources/dev/mycontrol.ascx’

For information on loading webforms and usercontrols from embedded resources take a look at http://www.codeproject.com/KB/aspnet/ASP2UserControlLibrary.aspx