gpt4 book ai didi

c# - MMC 管理单元和 .Net 4.x

转载 作者:行者123 更新时间:2023-11-30 13:47:59 30 4
gpt4 key购买 nike

我们最近将所有项目升级到 Visual Studio 2012 和 .Net 4.5。我们的大多数项目都有处理产品配置的自定义 MMC 管理单元。我现在了解到 MMC 3.0 本身并不处理 .Net 4.0 运行时,因为运行时在 MMC 3.0 发布后很长时间才发布。

我正在寻找一种方法来修复我们的管理单元,以便 MMC 在加载它们时不会崩溃,而且我遇到了很多提到添加 mmc.exe.config 文件的页面。我试过这个,但我无法让它工作。

我创建了一个以此为内容的文件:

<configuration>
<startup>
<supportedRuntime version='v4.0.20506' />
<requiredRuntime version='v4.0.20506' safemode='true' />
</startup>
</configuration>

我已将其作为 mmc.exe.config 保存在 windows\system32 和 windows\sysWOW64 目录中,但是此文件的存在没有任何区别。我的管理单元仍然崩溃并显示相同的错误消息:

Could not load file or assembly 'xxxx, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d62dabb4275ffafc' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

我需要做什么才能让 MMC 正确加载 .Net 4.0 运行时程序集?

最佳答案

对我来说,告诉 MMC 使用 v4 框架是有效的,我有 v4.0.30319

set COMPLUS_version=v4.0.30319
start SomeConsole.msc

检查解决方法: http://connect.microsoft.com/VisualStudio/feedback/details/474039/can-not-use-net-4-0-to-create-mmc-snapin

这是我的调试设置:enter image description here

我使用的是 32 位版本的控制台,还必须将以下内容添加到“c\Windows\SysWOW64\mmc.exe.config”中:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version='v4.0' />
</startup>
</configuration>

希望对你有帮助。 GL

关于c# - MMC 管理单元和 .Net 4.x,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14348930/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com