Using Moles with DLR (dynamic)
As several people have found, Moles does not work well with DLR. Check Cameron’s post for this issue.
In order to make it work do the following:
- Go to folder C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\
- Backup files Microsoft.Moles.VsHost.exe.Config / Microsoft.Moles.VsHost.x86.exe.Config (depending on your application’s platform)
- Modify the starup element and set the useLegacyV2RuntimeActivationPolicy to false in the .config file.
- Modify the legacyCasPolicy element and set the enabled to false the .config file.
Microsoft.Moles.VsHost.x86.exe
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="false">
<supportedRuntime version="v4.0" />
<supportedRuntime version="v2.0.50727" />
</startup>
<runtime>
<legacyCasPolicy enabled="false" />
</runtime>
</configuration>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="false">
<supportedRuntime version="v4.0" />
<supportedRuntime version="v2.0.50727" />
</startup>
<runtime>
<legacyCasPolicy enabled="false" />
</runtime>
</configuration>
I haven’t done further testing on changing the use of legacy CAS Policy when using Moles & VS Test Framework.
Let me know how it works for you.