我有另一个这些“无法加载文件或程序集或其依赖项之一”的问题。

附加信息:无法加载 文件或程序集 “Microsoft.Practices.Unity, Version = 1.2.0.0、文化=中立, 都31 bf3856ad364e35”或 它的依赖项之一。在位于 程序集的显式定义可以 不匹配程序集引用。 (异常来自HRESULT: 0x80131040)

我不知道是什么导致了这种情况,也不知道如何调试它来找到原因。

我在我的解决方案目录.csproj文件中做了一个搜索,我有Unity的每个地方:

参考 包括= " Microsoft.Practices.Unity, Version = 2.0.414.0、文化=中立, 都31 bf3856ad364e35, processorArchitecture = MSIL”

在我的任何项目中都找不到任何与1.2.0.0相反的参考。

我该怎么解决这个问题呢?


当前回答

下面的方法对我很有效。

删除临时文件C:\Windows\Microsoft.NET\Framework\v4.0.30319\临时ASP. net网络文件 然后右键单击临时Asp.net文件>属性>安全 并给予IIS和所有运行我的项目的用户完全控制访问权限

其他回答

另一个可能的原因是:确保没有意外地在项目属性中为两个项目指定相同的程序集名称。

步骤1: 删除现有引用 步骤2: 清洁解决方案 步骤3: 再次添加项目Reference。

搞定了。:)

微软企业库(由. nettiers引用)是我们的问题,它反过来引用了一个旧版本的Unity。为了解决这个问题,我们在web.config中使用了以下绑定重定向:

<configuration>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="Microsoft.Practices.Unity" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="1.0.0.0-2.0.414.0" newVersion="2.1.505.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="Microsoft.Practices.Unity.Configuration" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="1.0.0.0-2.0.414.0" newVersion="2.1.505.0" />
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
</configuration>

或者,您可能只想将Enterprise Library更新到最新版本。

在我的情况下,bin文件夹是一个名为Unity的非引用dll。MVC3,我试图在visual studio中搜索任何参考,没有成功,所以我的解决方案很简单,从bin文件夹中删除那个dll。

打开IIS管理器

选择应用程序池

然后选择您正在使用的池

进入高级设置(在右侧)

将“启用32位应用程序”的标志为true。