2017-07-14 60 views
0

將項目從網站項目轉換爲Web應用程序項目後,站點無法運行抱怨global.asax無法編譯因爲:全局asax無法編譯「模塊system.data.entity version = 4.0.0.0應引用」

Compiler Error Message: CS0234: The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?) 

但我引用System.Data.Entity。如果我刪除導入行並直接引用它,我會得到:

Compiler Error Message: CS0012: The type 'System.Data.Objects.DataClasses.EntityObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. 

但是我引用了System.Data.Entity。

我試圖從引用和刪除它重新添加了好幾次,以及刪除我的/ bin中/文件夾,並重新編譯等

我也曾嘗試手動引用/v4.0/系統.Data.Entity dll而不是來自/v4.5/的默認版本,但這也不起作用。

+0

是否https://stackoverflow.com/questions/9972426/the-type-or-namespace-name-entity-does-not命名空間 - 系統 - 數據的幫助? – mjwills

+0

不,沒有,我也嘗試過。我有一個更新 - Web應用程序是.net 4.5,它調用的項目是.net 4.0。我相信這不應該是一個問題,但儘管具有相同的版本標籤(v4.0.0.0),但system.data.entity dll看起來不同。 – Eterm

回答

0

添加下面的固定這個問題的web.config:

<compilation debug="true" targetFramework="4.5"> 
    <assemblies> 
     <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /> 
    </assemblies> 
</compilation> 
相關問題