Today, I faced one issue while working on one sample . And could not find solution in one go and error shown was not intuitive enough.
First let me share my environment. Windows 8 (64 bit), Visual Studio 2012, IIS8
I created an ASP.NET 2.0 web service using Visual Studio 2012 directly at IIS8. But as soon as, I tried to access my web service via browser I found the following error
As you can see from the error, it does not point to any cause.
For this error there could be one issue that IIS is not registered with ASP.NET. So to register it, I opened the command prompt with run as administrator and navigated to the folder C:\Windows\Microsoft.NET\Framework\v2.0.50727. I navigated to framework version 2.0 because I was accessing the ASP.NET 2.0 webservice. Now I required to run the following command
But as soon as I run the above command, I faced another error
Later, I found that my Operating System (Windows 8) that I am running is of 64 bit version. So again navigated 64bit version executable and it ran successfully
So you can see above the message “Finished installing ASP.NET <2.0.50727>”. Here in the above pic, if you see the red encircled area, I have ran here 64 bit version executable.
Also note, this issue arises only if you installed the IIS after installing Visual Studio.
Hope this would save lot of time of yours.
Few days back, I was migrating my application for VS2008 to VS2010 and it was done successfully except some people started running the application. They faced the error as below
“Could not load file or assembly ‘PresentationCore’ or one of its dependencies. An attempt was made to load a program with an incorrect format. ”
I tried to diagnose the problem and tried to find a solution.<!–more Continue reading… –>
So whenever you upgrade to VS 2008 to VS 2010 and also upgrade ASP.NET version to 4.0. And if your website hosted on IIS, when you open your VS 2010 IDE it prompt a message asking to upgrade to asp.net version to 4.0. When you say yes it upgrades the version at IIS.
So let’s come back to our original problem. When I diagnosed I found the machine was having 64bit OS.
And at IIS, there is setting “Enable 32-bit Applications” at application pool level that is by default set false . So if you are having 64 bit OS and your application target 32-bit applications then this property must be true.
So how to set it. I have included the images for IIS7. So first you need to know, which application pool your virtual directory points. So to check this
Goto -> cmd prompt -> type inetmgr -> click on your virtual directory and click on basic settings
Now you can see the Red oval that that is the name of Application pool set for this directory.
Now click on Application pool-> Click on DefaultAppPool -> and click on Advance settings.
Here you can see Red oval, I have set Enable 32-bit Applications to true. Now restart the IIS.
Now run your application and it must be working.