无法加载文件或程序集“JsonFx.Json”或其依赖项之一。尝试加载格式不正确的程序

时间:2014-06-10 14:45:42

标签: c# .net jsonfx

我正在尝试编译并运行包含一些外部DLL的Web应用程序。

应用程序编译时没有错误,但是当我运行它时,我收到以下错误:

  

无法加载文件或程序集“JsonFx.Json”或其依赖项之一。试图加载格式不正确的程序。

这个问题的两个最常见的解决方案似乎是在IIS服务器中启用32位应用程序,并确保解决方案不是在32位模式下编译某些项目而在64位模式下编译其他项目。我试过这两个,但无济于事。

非常感谢任何帮助。

装配加载跟踪:

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Windows\SysWOW64\inetsrv\w3wp.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = JsonFx.Json
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: JsonFx.Json | Domain ID: 34
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/workspace/<project name>/source/<project name>/
LOG: Initial PrivatePath = C:\workspace\<project name>\source\<project name>\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\workspace\<project name>\source\<Project name>\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\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:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/<project name>/b862caa3/ad6832cd/JsonFx.Json.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/<project name>/b862caa3/ad6832cd/JsonFx.Json/JsonFx.Json.DLL.
LOG: Attempting download of new URL file:///C:/workspace/<project name>/source/<project>/bin/JsonFx.Json.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.

2 个答案:

答案 0 :(得分:2)

我假设你是从Visual Studio在IIS Express中运行它。如果项目设置为编译为64位而不是32位,则需要启用64-bit IIS Express

步骤:

  1. 导航至:HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\WebProjects
  2. 确保有一个名为“Use64BitIISExpress”的REG_DWORD值。如果没有,请创建它。
  3. 将其值设置为1(默认值= 0)。

答案 1 :(得分:1)

我通过重新加载JsonFx.Json.dll修复了这个问题。我现在还不完全确定它为什么会起作用,这比没有首先工作更令人不舒服。