wpf `无法加载文件或程序集“Microsoft.Windows.Shell”,Prism - C#

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22304193/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 11:10:13  来源:igfitidea点击:

`Could not load file or assembly 'Microsoft.Windows.Shell` , Prism - C#

c#wpfprismmef

提问by Guy P

I'm trying to run PRISM (MEF) example project, but get this error:

我正在尝试运行 PRISM (MEF) 示例项目,但出现此错误:

Managed Debugging Assistant 'BindingFailure' has detected a problem in 'Prism4MefDemo.vshost.exe'.

Additional information: The assembly with display name 'Microsoft.Windows.Shell' failed to load in the 'Load' binding context of the AppDomain with ID 1. The cause of the failure was: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Windows.Shell, Version=3.5.41019.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

托管调试助手“BindingFailure”在“Prism4MefDemo.vshost.exe”中检测到问题。

附加信息:显示名称为“Microsoft.Windows.Shell”的程序集无法在 ID 为 1 的 AppDomain 的“加载”绑定上下文中加载。失败的原因是:System.IO.FileLoadException:无法加载文件或程序集“Microsoft.Windows.Shell, Version=3.5.41019.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35”或其依赖项之一。定位的程序集的清单定义与程序集引用不匹配。(来自 HRESULT 的异常:0x80131040)

I've tried to remove and manualy add reference to Microsoft.Windows.Shellbut still nothing.

我试图删除并手动添加对的引用, Microsoft.Windows.Shell但仍然没有。

The version of this DLL is 3.0.1.0, and not 3.5.41019.1as in the Exception.

此 DLL 的版本是3.0.1.0,而不是3.5.41019.1异常中的版本。

This is the line with the Excecption:

这是带有例外的行:

    protected override DependencyObject CreateShell()
    {
        return this.Container.GetExportedValue<ShellWindow>();
    }

How can I fix it? Thanks.

我该如何解决?谢谢。

采纳答案by Guy P

So after trying everything, I looked for others files in my computer (Microsoft.Windows.Shell.dll) and found newer version, as expected by the Exception (3.5.41019.1) in MicrosoftRibbon for WPF\V3.5folder.

因此,在尝试了一切之后,我在我的计算机 ( Microsoft.Windows.Shell.dll) 中查找了其他文件,并找到了更新版本,正如文件夹中的 Exception ( 3.5.41019.1)所预期的那样MicrosoftRibbon for WPF\V3.5

It is strang,because the latest version of the NuGetpackage is 3.0.1.

很奇怪,因为最新版本的NuGetis 3.0.1

Thanks anyway.

不管怎么说,还是要谢谢你。

回答by Rashad Annara

Finally I solved this issue by installing Multilingual App Toolkitfrom hereand Add Reference to "Microsoft.Windows.Shell.dll" from the location "C:\Program Files (x86)\Multilingual App Toolkit"or copy the dll to your private assembly folder and refer it.

最后我通过 从这里安装多语言应用程序工具包并从位置“C:\Program Files (x86)\Multilingual App Toolkit”添加对“Microsoft.Windows.Shell.dll”的引用 或将 dll 复制到您的私有程序集文件夹并参考它。

When you install Microsoft.Windows.Shell.dllfrom Nuget, it was installing v3.0.1, But the actual expected version was v3.5.41019.1. you ll get this new version from the above path.

当您从 Nuget安装Microsoft.Windows.Shell.dll时,它正在安装 v3.0.1,但实际预期版本是 v3.5.41019.1。您将从上述路径获得这个新版本。

Thanks

谢谢

回答by marcusvmg

Adding Microsoft.Windows.Shell.dll v3.5.41019.1 to your project references, would solve the problem.

将 Microsoft.Windows.Shell.dll v3.5.41019.1 添加到您的项目引用中,将解决问题。