无法加载文件或程序集'Microsoft.TeamFoundation.WorkItemTracking.Client.Cache'或它的一个依赖关系
我正在研究与TFS交互的Web应用程序。当我将应用程序上传到Windows Azure云时,我收到了此错误消息。无法加载文件或程序集'Microsoft.TeamFoundation.WorkItemTracking.Client.Cache'或它的一个依赖关系
感谢您的意见,以解决此问题。
粘贴下面是我收到
Server Error in '/' Application.
--------------------------------------------------------------------------------
Could not load file or assembly 'Microsoft.TeamFoundation.WorkItemTracking.Client.Cache' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.BadImageFormatException: Could not load file or assembly 'Microsoft.TeamFoundation.WorkItemTracking.Client.Cache' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.TeamFoundation.WorkItemTracking.Client.Cache' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Stack Trace:
[BadImageFormatException: Could not load file or assembly 'Microsoft.TeamFoundation.WorkItemTracking.Client.Cache' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +567
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +192
System.Reflection.Assembly.Load(String assemblyString) +35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +123
[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.TeamFoundation.WorkItemTracking.Client.Cache' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +11568240
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +485
System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +79
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +337
System.Web.Compilation.BuildManager.CallPreStartInitMethods() +280
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1167
[HttpException (0x80004005): Could not load file or assembly 'Microsoft.TeamFoundation.WorkItemTracking.Client.Cache' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11700976
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4869205
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
这是因为,你的项目正试图在64位环境中使用32位的DLL(蔚蓝)
为了解决这类问题,创建一个启动脚本
复制下面的启动脚本到一个文本文件,下面给出的命令,保存为“setup.cmd”。 然后包括这个文件到您的Web角色项目,将“复制本地” =真 然后打开给定的启动命令下面的ServiceDefinition.csdef中webrole标签内
<webrole > --your webrole
<Startup>
<Task commandLine="setup.cmd" executionContext="elevated" />
</Startup>
</webrole >
启动脚本粘贴如下:
%windir%\system32\inetsrv\appcmd set config -section:system.applicationHost/applicationPools /applicationPoolDefaults.enable32BitAppOnWin64:"True" /commit:apphost
我解决了这个问题,通过从我的asp.net web项目的bin文件夹中删除相应的DLL。
感谢和问候,
请您的答案更详细。例如一个示例代码。 – Luv
似乎这个答案是清晰的 - “从DLL文件夹中删除DLL” - 为我工作,没有示例代码等需要 –
如果BIN文件夹中的文件与服务器上安装的内容相冲突,可能会导致问题。如果TFS dll已经在服务器上,则不需要bin部署dll。在我的情况下,这是真的,并从垃圾箱删除他们解决了这个问题。 –
我通过设置在该网站使用的应用程序池的Advanced Settings
的Enable 32-Bit applications
选项True
解决了这个。
谢谢。我尝试了很多解决方案,但这对我有用。 – SeeTheC
此处也确认,运行脚本可解决问题。在ASP.NET应用启动时执行.cmd的任何方式? – AlexVPerl
在应用程序池中,单击“高级设置”,然后将“启用32位应用程序”设置为true。重新启动应用程序池。 – Jeppen