简体   繁体   English

MMC SnapIn和.Net 4.x.

[英]MMC SnapIn and .Net 4.x

We recently upgraded all of our projects to Visual Studio 2012 and .Net 4.5. 我们最近将所有项目升级到Visual Studio 2012和.Net 4.5。 Most of our projects have custom MMC snapins that handle product configuration. 我们的大多数项目都有自定义MMC管理单元来处理产品配置。 I've now learned that MMC 3.0 doesn't natively handle the .Net 4.0 runtime, since the runtime shipped long after MMC 3.0 was released. 我现在已经知道MMC 3.0本身并不处理.Net 4.0运行时,因为运行时MMC 3.0发布后运行时间很长。

I'm looking for a way to fix our snapins so that MMC doesn't crash when they are loaded and I've come across a lot of pages that mention adding an mmc.exe.config file. 我正在寻找一种方法来修复我们的管理单元,以便MMC在加载时不会崩溃,而且我遇到了许多提及添加mmc.exe.config文件的页面。 I've tried this, and I can't get it to work. 我试过这个,我无法让它发挥作用。

I've created a file with this as its contents: 我创建了一个文件,其内容如下:

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

I have saved this as mmc.exe.config in both the windows\\system32 and windows\\sysWOW64 directories, however the presence of this file makes no difference. 我已将其保存为windows \\ system32和windows \\ sysWOW64目录中的mmc.exe.config,但此文件的存在没有区别。 My snapins still crash with the same error message: 我的snapins仍然崩溃,并显示相同的错误消息:

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.

What do I need to do to get MMC to load .Net 4.0 runtime assemblies properly? 我需要做些什么才能让MMC正确加载.Net 4.0运行时程序集?

For me it works to tell MMC to use the v4 Framework, I've got v4.0.30319 对我来说,它告诉MMC使用v4框架,我有v4.0.30319

set COMPLUS_version=v4.0.30319
start SomeConsole.msc

Check the workarounds: http://connect.microsoft.com/VisualStudio/feedback/details/474039/can-not-use-net-4-0-to-create-mmc-snapin 检查变通方法: http//connect.microsoft.com/VisualStudio/feedback/details/474039/can-not-use-net-4-0-to-create-mmc-snapin

And this are my debug settings: 这是我的调试设置: 在此输入图像描述

I use the 32 bit version of the console, and also had to add the into the "c\\Windows\\SysWOW64\\mmc.exe.config" the following: 我使用32位版本的控制台,还必须将以下内容添加到“c \\ Windows \\ SysWOW64 \\ mmc.exe.config”中:

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

Hope it helps you. 希望它能帮到你。 GL GL

Take a look at comments on this page ( http://msdn.microsoft.com/en-us/library/ms692759%28VS.85%29.aspx ). 请查看此页面上的评论( http://msdn.microsoft.com/en-us/library/ms692759%28VS.85%29.aspx )。 It looks like managed MMC snap-ins can target at most framework 3.5. 看起来托管MMC管理单元可以定位到大多数框架3.5。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM