2012-07-30 318 views
3

我有一個ASP.NET 3.5解決方案,最近升級到.NET 4.0上運行。儘管如此,解決方案中的大多數項目似乎仍然是以.NET 3.5 Framework爲目標的。無法加載文件或程序集'System.Core,版本= 3.5.0.0'

這就是說,我現在無法調試任何這些項目。我得到以下錯誤:

 
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> 

但它確實沒有好。有人可以解釋爲什麼我得到這個錯誤信息以及如何解決它?謝謝!

+0

當您更改目標框架.NET 4從項目屬性在VS. – 2012-07-30 19:44:22

+0

我想它應該會自動更新引用改變目標框架爲4.0,但它沒有幫助 – 2012-07-30 20:04:31

+0

這可能是由於手動編輯,通常你需要單獨更改每個項目的目標框架,我可以建議你創建一個.net4項目相同的類型,並嘗試比較.csproj文件來源以找出差異。 – 2012-07-30 20:50:34

回答

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"/>爲好。

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之一。有時候,當我需要處理不同的框架時,我刪除了目標框架行。

相關問題