Even though many others have blogged solutions to this issue (presenting a wide variety of potential workarounds, I might add), I'm posting this anyway for my own reference. I'd especially like to log the details specific to my situation as I'm seeing it a bit too much lately on my production (hosted) site.
Some suggest deleting temporary internet files, another suggests making a small change to the web.config file, Rick Strahl suggests a full recompile, and Scott Guthrie talks about the official Microsoft hotfix and suggested workarounds.
Before I get into the solution, I'll take a moment to look at my situation and the symptoms I was seeing.
The Symptoms
I'm running a Silverlight control, hosted in an ASP.NET web app which also hosts a WCF service. When I load up the main web aspx page my Silverlight control doesn't do anything. IE displays the yellow error icon in the lower left; clicking on it brings up this:
Copying error details yields:
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; Tablet PC 2.0; OfficeLivePatch.1.3; .NET CLR 3.0.30729; OfficeLiveConnector.1.4)
Timestamp: Thu, 16 Jul 2009 00:32:45 UTC
Message: Unhandled Error in Silverlight 2 Application An exception occurred during the operation, making the result invalid. Check InnerException for exception details. at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
at TagCloud.TagCloudControl.TagCloudService.GetTagsCompletedEventArgs.get_Result()
at TagCloud.TagCloudControl.Page.tagCloudService_GetTagsCompleted(Object sender, GetTagsCompletedEventArgs e)
at TagCloud.TagCloudControl.TagCloudService.TagCloudServiceClient.OnGetTagsCompleted(Object state)
Because this Silverlight control calls into a WCF service (and because I'd seen this exception before), I immediately went to my service's .svc file. Trying to bring that up in the browser brought up this:
Could not load file or assembly 'App_Web_ivxpj_7c, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
The Solution(s)
There's more than one solution to this problem. I'll detail the ones I found, but keep in mind people have had various levels of success with most of them.
- If you're seeing this problem on your development machine, do a full recompile. This one seemed to do the trick… sometimes.
- If you're seeing this problem on your development machine, delete temporary internet files. I had no success with this one.
- If you're seeing this problem on your development machine, remove and re-add the WCF service dll reference (assuming you have a dll reference). This is a home-grown solution which worked every time for me but was kind of a pain.
- If you're seeing this problem on your (hosted) server, copy over the service code or dll, overwriting the existing file(s). This should force a recompile by IIS. I have had good success with this one.
- Modify your web.config by adding the batch attribute. I haven't tried this one yet, though others have reported success with it.
1: <system.web>
2: <compilation defaultLanguage="c#" debug="false" batch="false"/>
3: </system.web>
I am looking forward to trying solution #4, but I'm hesitant to deploy any changes to my web.config. I just got everything working again. ;-)