Long blog title, I know. Yesterday, I ran into a issue/bug that I've never encountered during my years of being an ASP.NET developer. The error message is below:
The interesting thing about this error, is that it's occurred so often that there's a KB article (KB896181) for it that tells you how to fix it. Fortunately for me, I didn't have to apply the fix in the KB. I just had to change some of my security settings to give the account hosting the website the right permissions.
Here's how the errors occurs:
So you have an ASP.NET page that calls a web service. This can be done within its code-behind or within a control that the page is hosting. The big thing here is that you have a web page calling a web service.
Although you've created a proxy for the web service you plan to call, its base class SoapHttpClientProtocol still needs to create a temporary serialization assembly and cache its contents within the constructor. So, when you new-up that proxy, you run into this error.
Why you might not run into this issue:
By default, every ASP.NET web application runs as the ASPNET account, along with the IWAM_ComputerName account that runs any of the out-of-process applications for IIS. If you haven't changed any of these default settings, more than likely you haven't encountered this bug. However, if you're running your ASP.NET application as a different Windows user to tighten down security, you have a greater chance of getting the error.
That's the reason why I encountered it! We're hosting our application in IIS 6.0 and I've created a new AppPool to run the application as a user with minimal rights. Doing so, we can use Windows integrated security for connecting to remote resources like file shares, SQL Servers, etc.
For those running into the similar issue, I hope this post helps you!