VS2010集加载错误 [英] VS2010 Assembly Load Error

查看:151
本文介绍了VS2010集加载错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误,当我尝试在Visual Studio 2010来构建ASP.NET 4项目:无法加载文件或程序集文件:/// C:\\开发\\项目\\干线\\ BIN \\ ELMAH 。.DLL或它的一个依赖,不支持操作(从HRESULT异常:0x80131515)。

I am getting the following error when I try to build an ASP.NET 4 project in Visual Studio 2010: "Could not load file or assembly 'file:///C:\Dev\project\trunk\bin\Elmah.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)".

我已经验证该DLL呢,其实,存在的,是越来越正确地复制到bin文件夹。我也尝试删除,然后重新添加引用到项目中。

I have verified that the dll does, in fact, exist, and is getting copied to the bin folder correctly. I have also tried removing and then re-adding the reference to the project.

当我切换解决方案配置到释放构建只有失败。当解决方案配置设置它不会失败调试。

The build only fails when I switch the Solution Configuration to "Release". It does not fail when the Solution Configuration is set to "Debug".

(我知道的)的两种配置之间唯一的区别示于下面的Web.config变换,Web.Release.config:

The only difference between the two configurations (that I know of) is shown in the following Web.config transform, 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>

我一直在使用融合日志查看器来跟踪程序集绑定的问题试过,但它看起来是发现和正确加载程序集。这里是日志:

I have tried using Fusion Log Viewer to track down the assembly binding issue, but it looks like it is finding and loading the assembly correctly. Here is the log:

*** 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.

我觉得有我的一部分,究竟是怎么回事缺乏基本的了解。任何解释/帮助是非常AP preciated!

I feel like there is a fundamental lack of understanding on my part as to what exactly is going on here. Any explanation/help is much appreciated!

推荐答案

可能是太晚了,我已经经历了这个问题。就我而言,我固定以下这说明我在一个评论中发现(感谢托马斯!)中的这个帖子

Could be too late, I've experienced this issue. In my case, I fixed following this instructions I found in a comment (Thanks Thomas!) in this post

在约做同样在App.config的开发IT'注释会谈。其实必须是在其他地方。按照后面的说明。

In the 'Developer IT' comment talks about do the same in the app.config. Actually must be in other place. Follow the instructions behind.

这是更好的解决方案是修复微软的SGEN分布。首先找到SGEN(例如,我的系统上的.NET 4.0是在C:\\ Program Files文件\\微软的SDK \\ WINDOWS \\ v7.0A \\ BIN \\ NETFX 4.0工具。)接下来,创建文件sgen.exe。配置与内容:

An even better solution is to "fix" Microsoft's sgen distribution. First find sgen (for example, on my system for .Net 4.0 it is in "C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools".) Next, create the file sgen.exe.config with the contents:

<configuration> 
  <runtime> 
    <loadFromRemoteSources enabled="true" /> 
  </runtime> 
</configuration> 

问题的关键是,将在SGEN应用程序配置文件设置为true loadFromRemoteResources允许SGEN正确地从ClearCase的卷加载文件。我知道。我碰到同样的问题,这是我的固定它。

The point is, adding loadFromRemoteResources set to true in the sgen app config file allows sgen to properly load files from ClearCase volumes. I know. I've run into the same problem and this is how I fixed it.

请注意,在某些时候微软可能会创建应用程序配置文件,所以如果你做到这一点,首先检查该文件不存在,如果确实如此,检查它是否还需要设置。

Note that at some point Microsoft may create the app config file, so if you do this, first check that the file doesn't already exist, and if it does, check if it still needs the setting.

这篇关于VS2010集加载错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆