Pregunta

We recently upgraded all of our projects to Visual Studio 2012 and .Net 4.5. Most of our projects have custom MMC snapins that handle product configuration. 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.

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. 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. My snapins still crash with the same error message:

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?

¿Fue útil?

Solución

For me it works to tell MMC to use the v4 Framework, I've got 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

And this are my debug settings:enter image description here

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:

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

Hope it helps you. GL

Otros consejos

Take a look at comments on this page (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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top