Dailycode.info

Short solution for short problems

IIS: What triggers recycle of a website in IIS?

A colleague and me where thinking about this, because we were copying files to the root directory of the web site. But no worries, this doesn't trigger a recycle. What does trigger a recycle?


Trigger Immediate Recycle

  • Web.config changes
  • Machine.config changes
  • Global.asax changes
  • Bin directory changes
  • App_Code changes

HTTP Error 500.19 - Internal Server Error

After getting a latest version of the source files of my web project I got this error:

HTTP Error 500.19 - Internal Server Error

The requested page cannot be accessed because the related configuration data for the page is invalid.

The solution was to set the application pool to network identity and provide this user read access to the files of my web site.


GAC vs BIN (What dll version will be loaded?)

Global assembly cache versus BIN folder.
If you are frequently updating the Assembly, then you always better to deploy it in BIN.  Since, Assembly will be reloaded automatically just after the updating.    But when you update the Assembly in GAC, you have to restart the IIS (IISRESET) to grab the new version. The reason is GAC keeps the assembly in Cache. You can use different versions of the same DLL across applications, but not the same dll with different versions in the same BIN.
When you deploy your Assembly on GAC then you can access the Assembly from any web application. But when you deploy Assembly in web application’s BIN folder, then it can only access from the given web application. Anyway, if you have all-purpose web part, you better to deploy it in GAC and avoid the multiple Assembly deployments in BIN.
If you have multiple versions of same Assembly used in 1 application, then you have to deploy it in GAC. Because the GAC manages the multiple version of given Assembly, but BIN doesn’t.
I found this information here.
Next question is what order will the assemblies be used. I’ve read something like .Net will look for the highest version in the BIN and GAC and use that one, or others say the BIN has priority over the GAC.
So I did the test.
First I deployed a simple website that has a textbox and a button. When you click the button you will get the assembly version of a referenced class library. I placed a version 1.2.0.0 of the dll in theGAC.
  
 I tested 4 scenarios:
1: The class library referenced is of version 1.0.0.0 and the dll is located in the bin folder
2: The class library referenced is of version 1.1.0.0 and the dll is located in the bin folder
3: The class library referenced is of version 1.1.0.0 and the dll is NOT located in the bin folder
4: The class library referenced is of version 1.2.0.0 and the dll is NOT located in the bin folder
So the result is that the BIN folder has priority over the GAC. In example 1 we will retrieve the 1.0.0.0 version of the dll.  
 
In the second example we will see the 1.1.0.0 version of the dll that is in the BIN folder.
 
Then we will get an error, since the project is build against the 1.1.0.0 and the GAC version is 1.2.0.0.
 
And the fourth example shows the GAC version. 
There are methods to force your web application to use certain versions of dll. Adding the required version to your config file can do the trick.

Cannot get WCF hosting to work

 

We were trying to setup hosting outside of the visual studio internet web host. First tried it on the server, no problem. Then we tried it locally on our machine. I noticed that the IIS was not properly installed, so I installed it properly. Still the hosting was not working. It was giving a strange error this time:

Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral

Then I looked this up and discovered that the problem was that IIS was installed after the .Net Framework 4.0. This was giving problems especially for WCF services.

 

So the solution is simple, open the visual studio 2010 prompt and execute this command:

aspnet_regiis.exe –iru

 

This should solve your problem.

Solution found here.