Could not load file or assembly 'System.Core, Version=18.104.22.168'
I have an ASP.NET 3.5 solution that was recently upgraded to run on .NET 4.0. Despite that, it seems that most of the projects in the solution are still set to target the .NET 3.5 Framework.
That being said, I can't debug any of these projects now. I get the following error:
Parser Error Message: Could not load file or assembly 'System.Core, Version=22.214.171.124, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
=== Pre-bind state information === LOG: User = myusername LOG: DisplayName = System.Core, Version=126.96.36.199, Culture=neutral, PublicKeyToken=31bf3856ad364e35 (Fully-specified) LOG: Appbase = file:///C:/Projects/myprojectpath/ LOG: Initial PrivatePath = C:\Projects\myprojectpath\bin Calling assembly : (Unknown). === LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Projects\myprojectpath\web.config LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config. LOG: Post-policy reference: System.Core, Version=188.8.131.52, Culture=neutral, PublicKeyToken=31bf3856ad364e35 LOG: The same bind was seen before, and was failed with hr = 0x80070002.
I have edited my project file manually, as described here and added the following lines:
<Reference Include="System.Core"> <RequiredTargetFramework>3.5</RequiredTargetFramework> </Reference>
But it did no good. Can someone explain why I'm getting this error message and how to resolve it? Thanks!
In my case, there was a line in the web.config that had to be removed.
<pages enableEventValidation="true"> <namespaces> <add namespace="System.Linq"/> </namespaces> <controls> <!--<add tagPrefix="asp" namespace="System.Linq" assembly="System.Core, Version=184.108.40.206, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>--> </controls> </pages>
(And actually I was able to safely comment out <add namespace="System.Linq"/> as well.
It happened to me that the controls used such as:
<assemblies> <add assembly="System.Core, Version=220.127.116.11, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> </assemblies>
<assemblies> <add assembly="System.Core, Version=18.104.22.168, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> </assemblies>
Or vice versa. You might wanna check that out. Or migrate the whole project (the frames or pages) to a .net 4.0 one. And also sometimes when I need to work on diferent frameworks I remove the target framework line.