我遇到了DLL的问题,其中一个Web角色运行良好而另一个不是由于无法加载它们都使用的DLL而导致的。
我有几个Web角色项目,一个名为A.B,另一个名为A.B.C. 它们都引用了一个名为A.Lib的lib项目。 在本地运行工作。
将构建上传到Azure后,一个Web角色运行良好(A.B.C),而另一个(A.B)似乎无法加载DLL(A.Lib)。
我试图创建一个名为D的新Web角色,它与A.B.C完全相同,但将D角色命名为D& A.B运作良好。
任何想法???
以下是来自Web角色的融合日志(从Windows事件查看器中提取)的日志:
Unable to determine role entry point type from provided Assembly. Process ID: 3176, Process Name: WaIISHost Role entrypoint could not be created: System.TypeLoadException: Unable to load the role entry point due to the following exceptions:
-- System.IO.FileNotFoundException: Could not load file or assembly 'A.Lib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
or one of its dependencies. The system cannot find the file specified.
File name: 'A.Lib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
Assembly manager loaded from: D:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable E:\base\x64\WaIISHost.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = A.Lib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///E:/approot/bin
LOG: Initial PrivatePath = E:\approot\bin
Calling assembly : A.B, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: E:\base\x64\WaIISHost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from D:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///E:/approot/bin/A.Lib.DLL.
LOG: Attempting download of new URL file:///E:/approot/bin/A.Lib/A.Lib.DLL.
LOG: Attempting download of new URL file:///E:/approot/bin/A.Lib.EXE.
LOG: Attempting download of new URL file:///E:/approot/bin/A.Lib/A.Lib.EXE.
-- System.IO.FileNotFoundException: Could not load file or assembly 'A.Lib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'A.Lib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
Assembly manager loaded from: D:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable E:\base\x64\WaIISHost.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = A.Lib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///E:/approot/bin
LOG: Initial PrivatePath = E:\approot\bin
Calling assembly : A.B, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: E:\base\x64\WaIISHost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from D:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetRoleEntryPoint(Assembly entryPointAssembly)
--- End of inner exception stack trace ---
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetRoleEntryPoint(Assembly entryPointAssembly)
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.CreateRoleEntryPoint(RoleType roleTypeEnum)
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRoleInternal(RoleType roleTypeEnum)
解决方案: 我发现A.B.C引用了A.B因此引起了这个问题,我仍然不明白为什么......这两个(A.B& A.B.C)在两个完全不同的VM上。 因此,如果有人遇到此问题,请确保一个项目不包含对另一个项目的引用。