當我嘗試在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