Friday, June 12, 2009

Could not load file or assembly 'System.Core, Version=2.0.5.0

Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.

I've had about all I can take from this error. It occurs randomly, out of nowhere, when I try to compile anything in VSTS and a Silverlight project (of any type, xap, dll, etc) exists in that compile sequence.

Up until now the only fix I have found is to exit all instances of Visual Studio and load them back up. This makes the error go away for at least one compile.

Well, having put up with just about enough out of Silverlight, I have another fix that is technically not something you would normally want to do. Add System.Core.dll to the Global Assembly Cache (GAC).

Search for the System.Core.dll relating to Silverlight (likely at C:\Program Files\Microsoft Silverlight\2.x) and use the gacutil.exe to add it.

After doing this, the problem has not reoccurred for me.

4 comments:

Mike

did the trick, thanks!

Rexicus

This was the answer I needed. Woohoo. Let me add some keywords hoping that it will help someone else find this:
Silverlight 4
System.windows.dll
"Could not load file or assembly 'System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified."
Silverlight 4 toolkit

Thanks again. I've already blown a day on this in the middle of a tight deadline.

Arik

Thank!
thank you too Rexicus
with your Keywords i was able to trace this post...
you just save me a lot of frustration and headache ...

Tim Abell

I think (but am not certain) that this is likely a result of adding a silverlight project as a normal project reference to a web project, this causes dlls of your silverlight project to be copied into your main web project's bin folder, thus for some reason causing the error seen.

Remove the silverlight project reference, make sure the dlls are gone from bin\, and add a proper silverlight reference if it's missing (right click the web project, click the "silverlight applications" tab, click add... etc), this will cause the clientbin\ directory to be updated instead, which doesn't cause the conflict.

probably.

related information:
http://devexpress.com/Support/Center/p/Q249490.aspx

http://stackoverflow.com/search?q=silverlight+system.core

I haven't found a definitive cause, but you are not alone for sure.