views:

255

answers:

2

I've been working on converting a Silverlight project from Silverlight 2 to Silverlight 3. Note that I've never had SL 2 binaries or development components installed on my machine (it's only a month old).

This has been going fine and the app was running until I started getting a build error with ValidateXaml raising a FileNotFoundException in System.Core. I don't know why this suddenly started happening but from some searching around the answer seemed to be putting various Silverlight DLLs in the GAC. This did indeed solve the build errors. I didn't try testing to check if the app ran correctly after that.

Some time later I'm trying to run the app again. Now I'm getting yet another FileNotFoundException, this time in System.Windows.Controls. I've tried removing all Silverlight DLLs from the GAC and adding them back in again without any success. Here's the stack trace:

Message: Unhandled Error in Silverlight Application 
Code: 4004    
Category: ManagedRuntimeError       
Message: System.IO.FileNotFoundException: Could not load file or assembly 'System.Windows.Controls, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Windows.Controls, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
   at MyNamespace.Page.InitializeComponent()
   at MyNamespace.Page..ctor()
   at MyNamespace.App.Application_Startup(Object sender, StartupEventArgs e)
   at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)     

This entire experience has been very frustrating and I'd love to know what is causing these problems and how to fix them?

+1  A: 

Have you tried the fusion log viewer? In a VS command shell, fuslogvw.exe, set it to show bind errors in options, clear out the log, run your app. Afterwards it will give you a detailed explanation why it could not load the assembly. fuslogvw has helped me here many times.

Do note the or one of its dependencies. That is key, it's rare that it's the assembly the exception is complaining about, it's often a dependency issue.

Matt Greer
Thank you, I'd completely forgotten about this tool!
Alex Angas
A: 

I have reinstalled the Silverlight runtime and all of the development components and the problem has now gone away.

I'm leaving this unanswered for now in case someone has some ideas on what caused this.

Alex Angas