无法加载文件或程序集'System.Core,Version = 3.5.0.0'

时间:2012-07-30 18:58:23

标签: asp.net .net visual-studio-2010 visual-studio asp.net-4.0

我有一个最近升级为在.NET 4.0上运行的ASP.NET 3.5解决方案。尽管如此,似乎解决方案中的大多数项目仍然是针对.NET 3.5 Framework。

话虽如此,我现在无法调试任何这些项目。我收到以下错误:

Parser Error Message: Could not load file or assembly 'System.Core, Version=3.5.0.0, 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=3.5.0.0, 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=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
LOG: The same bind was seen before, and was failed with hr = 0x80070002.

我已按照here所述手动编辑了我的项目文件,并添加了以下几行:

<Reference Include="System.Core">
  <RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>

但它并没有好处。有人可以解释为什么我收到此错误消息以及如何解决它?谢谢!

2 个答案:

答案 0 :(得分:1)

我发现使用的控件如:

<assemblies>
            <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

        </assemblies>

相反:

 <assemblies>
            <add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

        </assemblies>

反之亦然。你可能想检查一下。或者将整个项目(框架或页面)迁移到.net 4.0。有时当我需要处理不同的框架时,我会删除目标框架行。

答案 1 :(得分:1)

就我而言,web.config中有一行必须删除。

<pages enableEventValidation="true">
    <namespaces>
        <add namespace="System.Linq"/>
    </namespaces>
    <controls>
        <!--<add tagPrefix="asp" namespace="System.Linq" assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>-->
    </controls>
</pages>

(实际上我也可以安全地评论<add namespace="System.Linq"/>

相关问题