2012-04-30 37 views
1

我的ASP.NET MVC 4應用程序在IIS和IEExpress環境中運行完美。 不幸的是它似乎有不同版本的EntityFramework有問題。 對於EF 4.1.0.0的發生,所有參考文獻都進行了雙重檢查和tripple檢查。目前所有的EF 4.3.0.0都沒有。 某處系統似乎對4.1.0.0有參考,並試圖找到它。沒有成功。Azure找不到引用EntityFramework

所有相關的外部庫被標記爲「複製本地=真正的」

Microsoft.WindowsAzure.ServiceRuntime Critical: 201 : Role entrypoint could not be created: 
System.TypeLoadException: Unable to load the role entry point due to the following exceptions: 
-- System.IO.FileLoadException: Die Datei oder Assembly "EntityFramework, Version=4.1.0.0,  Culture=neutral, PublicKeyToken=b77a5c561934e089" oder eine Abhängigkeit davon wurde nicht gefunden.  Die gefundene Manifestdefinition der Assembly stimmt nicht mit dem Assemblyverweis überein. (Ausnahme von HRESULT: 0x80131040) 
Dateiname: "EntityFramework, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" 

=== Zustandsinformationen vor Bindung === 
LOG: Benutzer = COREI7\markus 
LOG: DisplayName = EntityFramework, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
(Fully-specified) 
LOG: Appbase = file:///D:/Dev/TFS/BettrFit/BettrFit.Azure/csx/Debug/roles/BettrFit/approot/bin 
LOG: Ursprünglicher PrivatePath = D:\Dev\TFS\BettrFit\BettrFit.Azure\csx\Debug\roles\BettrFit\approot\bin 
Aufruf von Assembly : System.Web.Http.Data.EntityFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35. 
=== 
LOG: Diese Bindung startet im default-Load-Kontext. 
LOG: Es wurde keine Anwendungskonfigurationsdatei gefunden. 
LOG: Die Hostkonfigurationsdatei wird verwendet: 
LOG: Die Computerkonfigurationsdatei von C:\Windows\Microsoft.NET\Framework64\v4.0.30319 \config\machine.config wird verwendet. 
LOG: Verweis nach der Richtlinie: EntityFramework, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 
LOG: Download von neuem URL file:///D:/Dev/TFS/BettrFit/BettrFit.Azure/csx/Debug/roles/BettrFit/approot/bin/EntityFramework.DLL. 
WRN: Der Vergleich des Assemblynamens führte zum Konflikt: Nebenversion. 
ERR: Das Setup der Assembly konnte nicht abgeschlossen werden (hr = 0x80131040). Die Suche wurde beendet. 

---> System.Reflection.ReflectionTypeLoadException: Mindestens ein Typ in der Assembly kann nicht geladen werden. Rufen Sie die LoaderExceptions-Eigenschaft ab, wenn Sie weitere Informationen benötigen. 
    bei System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) 
    bei System.Reflection.RuntimeModule.GetTypes() 
    bei System.Reflection.Assembly.GetTypes() 
    bei Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetRoleEntryPoint(Assembly entryPointAssembly) 
    --- Ende der internen Ausnahmestapelüberwachung --- 
    bei Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetRoleEntryPoint(Assembly entryPointAssembly) 
    bei Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.CreateRoleEntryPoint(RoleType roleTypeEnum) 
    bei Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRoleInternal(RoleType roleTypeEnum) 
Das Programm "[2372] WaIISHost.exe: Verwaltet (v4.0.30319)" wurde mit Code -1 (0xffffffff) beendet. 

希望你們能就如何解決這個問題的一些提示。

我調查了Data.EntityFramework組件:

Assembly a = System.Reflection.Assembly.Load("System.Web.Http.Data.EntityFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"); 

foreach (AssemblyName i in a.GetReferencedAssemblies()) 
{ 
    Trace.TraceInformation("Ref Assemblies:" + i.Name+" "+i.Version); 
} 

這表明,其根據的EntityFramework 4.1.0.0爲默認值。 我怎麼能改變它? Web.Config似乎沒有在加載時使用 - 在這裏我已經嘗試了重新綁定。

+0

您是否還檢查了可能在本地安裝(在全局程序集緩存中)並在Azure中缺少的間接引用?看看http://stackoverflow.com/a/10142356/468244 +評論。 –

+0

我用GACViewer檢查 - 目前爲止沒有運氣。我懷疑System.Web.Http.Entityframework可能會導致問題。 但我不知道如何檢查lib所引用的版本。 在日誌中它被命名爲Calling Assembly。我怎樣才能將它配置爲使用「更新」版本,因爲它與包一起部署? – Obiwan007

回答

0

請儘量使用匯編重定向重定向到4.1.0.0 4.3.0.0:

<runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
    <dependentAssembly> 
     <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" /> 
     <bindingRedirect oldVersion="4.0.0.0 - 4.2.0.0" newVersion="4.3.0.0"/> 
    </dependentAssembly> 
    </assemblyBinding> 
</runtime> 

最好的問候,

徐明。

+0

對不起。我的web.config包含altready這樣的重定向。也嘗試過你 - 沒有運氣。 看來,系統忽略了web.config運行時間部分。 – Obiwan007

2

我通過提供一個app.config文件和我的Web角色項目來修復它。 似乎Azure啓動代碼使用的是App.Config文件,而不是通常使用的Web.Config。

我的app.config添加了runtime/assemplyreferences重定向綁定代碼。