当我尝试在Visual Studio 2010中生成ASP.NET 4项目时出现以下错误:“无法加载文件或程序集”文件:/// C:\ Dev \ project \ trunk \ bin \ Elmah.dll'或它的一个依赖项,操作不受支持(来自HRESULT的异常:0x80131515)“。VS2010程序集加载错误
我已经验证dll确实存在,并且正确地将其复制到bin文件夹中。我也尝试删除,然后重新添加项目的引用。
当我将解决方案配置切换到“发布”时,构建只会失败。当解决方案配置设置为“调试”时,它不会失败。
两个配置之间唯一的区别(即我知道的)示于以下的Web.config变换,Web.Release.config:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="SqlServer" connectionString="" providerName="System.Data.SqlClient" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<customErrors mode="On" xdt:Transform="Replace">
<error statusCode="404" redirect="lost.htm" />
<error statusCode="500" redirect="uhoh.htm" />
</customErrors>
</system.web>
</configuration>
我已经使用融合日志查看器来跟踪尝试程序集绑定问题,但它看起来像正在查找并加载程序集。这里是日志:
*** Assembly Binder Log Entry (6/8/2010 @ 10:01:54 AM) ***
The operation was successful.
Bind result: hr = 0x0. The operation completed successfully.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\sgen.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = User
LOG: Where-ref bind. Location = C:\Dev\project\trunk\bin\Elmah.dll
LOG: Appbase = file:///c:/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/bin/NETFX 4.0 Tools/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = sgen.exe
Calling assembly : (Unknown).
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Attempting download of new URL file:///C:/Dev/project/trunk/bin/Elmah.dll.
LOG: Assembly download was successful. Attempting setup of file: C:\Dev\project\trunk\bin\Elmah.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: Elmah, Version=1.1.11517.0, Culture=neutral, PublicKeyToken=null
LOG: Re-apply policy for where-ref bind.
LOG: Where-ref bind Codebase does not match what is found in default context. Keep the result in LoadFrom context.
LOG: Binding succeeds. Returns assembly from C:\Dev\project\trunk\bin\Elmah.dll.
LOG: Assembly is loaded in LoadFrom load context.
我觉得我有一个根本的缺乏理解,在这里究竟是怎么回事。任何解释/帮助非常感谢!
0x80131515是COR_E_NOTSUPPORTED,即某事正在抛出一个NotSupportedException。但是,浏览Elmah源代码时除了包含的程序集外,没有对NotSupportedException的引用: -/ – Rup 2010-06-08 16:30:10
在我看来,这可能是Visual Studio 2010问题。但是,这当然只是一个猜测。关闭寻找解决方法! – 2010-06-08 16:45:19