2012-04-30 112 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重定向绑定代码。