Unit tests throw exception when run in debug mode

I've been using unit tests for years, and I started using Resharper to run them as soon as Resharper offered support. We use nunit V2.7.

Today when I needed to run a unit test with the debugger. an exception is raised in the resharper task runner code before it gets to my code. The test runs and passes if I do not use the debugger. VisualStudio posts a managed debugging assistant which says:

The assembly named 'JetBrains.ReSharper.TaskRunnerFramework' was loaded from 'file:///C:/Program Files/JetBrains/ReSharper/v3.1/vs9.0/Bin/JetBrains.ReSharper.TaskRunnerFramework.DLL' using the LoadFrom context. The use of this context can result in unexpected behavior for serialization, casting and dependency resolution. In almost all cases, it is recommended that the LoadFrom context be avoided. This can be done by installing assemblies in the Global Assembly Cache or in the ApplicationBase directory and using Assembly.Load when explicitly loading assemblies..

Here's the last three calls in the stack:

JetBrains.ReSharper.TaskRunnerFramework.dll!JetBrains.ReSharper.TaskRunnerFramework.TaskRunnerHostBase.GetRunner(string runnerID = "nUnit") Line 50 + 0x18 bytes C#
JetBrains.ReSharper.TaskRunnerFramework.dll!JetBrains.ReSharper.TaskRunnerFramework.TaskRunnerHostBase.DeserializeTask(System.Xml.XmlNode element = Cannot evaluate expression because the code of the current method is optimized.) Line 100 + 0xc bytes C#
JetBrains.ReSharper.TaskRunnerFramework.dll!JetBrains.ReSharper.TaskRunnerFramework.TaskRunnerHostBase.DeserializeChildren(System.Xml.XmlNode element = Cannot evaluate expression because the code of the current method is optimized., System.Collections.Generic.ICollection<JetBrains.ReSharper.TaskRunnerFramework.TaskExecutionNode> nodes = Count = Cannot evaluate expression because the code of the current method is optimized.,

JetBrains.ReSharper.TaskRunnerFramework.TaskExecutionNode parent = null) Line 85 + 0xb bytes C#

I am running
resharper version 3.1.584.3
VS2008
.Net 3.5

Thanks,

Mitch

5 comments

Hello,

So, what is the exception? Did you see it in the debugger?


Serge Baltic
JetBrains, Inc — http://www.jetbrains.com
“Develop with pleasure!”


0

I have a similar problem. When I debug with nUnit in VS 2008 I get a LoadFromContext warning with similar description. Are there any fixes to this problem yet?

0

Hi,


I also have this problem:

First a message box appears saying:

---------------------------
Microsoft Visual Studio
---------------------------
There is no source code available for the current location.
---------------------------
OK 
---------------------------

After clicking ok:


LoadFromContext was detected


The assembly named 'JetBrains.ReSharper.TaskRunnerFramework' was loaded from 'file:///C:/Program Files (x86)/JetBrains/ReSharper/v3.1/vs9.0/Bin/JetBrains.ReSharper.TaskRunnerFramework.DLL' using the LoadFrom context. The use of this context can result in unexpected behavior for serialization, casting and dependency resolution. In almost all cases, it is recommended that the LoadFrom context be avoided. This can be done by installing assemblies in the Global Assembly Cache or in the ApplicationBase directory and using Assembly.Load when explicitly loading assemblies.


OK     CONTINUE


(if you click OK, it stops unit testing but stays in debug mode; CONTINUE just raises the "LoadFromContext was detected" box again)


CallStack:

     [External Code]  
     JetBrains.ReSharper.TaskRunnerFramework.dll!JetBrains.ReSharper.TaskRunnerFramework.TaskRunnerHostBase.GetRunner(string runnerID = "nUnit") Line 47 + 0x14 bytes    C#
     JetBrains.ReSharper.TaskRunnerFramework.dll!JetBrains.ReSharper.TaskRunnerFramework.TaskRunnerHostBase.DeserializeTask(System.Xml.XmlNode element = Cannot evaluate expression because the code of the current method is optimized.) Line 107 + 0xb bytes    C#
     JetBrains.ReSharper.TaskRunnerFramework.dll!JetBrains.ReSharper.TaskRunnerFramework.TaskRunnerHostBase.DeserializeChildren(System.Xml.XmlNode element = Cannot evaluate expression because the code of the current method is optimized., System.Collections.Generic.ICollection<JetBrains.ReSharper.TaskRunnerFramework.TaskExecutionNode> nodes = Count = Cannot evaluate expression because the code of the current method is optimized., JetBrains.ReSharper.TaskRunnerFramework.TaskExecutionNode parent = null) Line 91 + 0xb bytes    C#
     JetBrains.ReSharper.TaskRunnerFramework.dll!JetBrains.ReSharper.TaskRunnerFramework.TaskRunnerHostBase.DeserializeTree(string nodeSerialized = "<TaskList><Task type=\"JetBrains.ReSharper.UnitTestProvider.nUnit.NUnitTestFixtureTask\" runnerID=\"nUnit\" TypeName=\"XXX.abcTest\" AssemblyLocation=\"C:\\XXX\\ABC.dll\" Explicitly=\"false\"><TaskList><Task type=\"JetBrains.ReSharper.UnitTestProvider.nUnit.NUnitTestTask\" runnerID=\"nUnit\" TestMethod=\"TestABC\" TestType=\"XXX.abcTest\" Explicitly=\"false\" /><Task type=\"JetBrains.ReSharper.UnitTestProvider.nUnit.NUnitTestTask\" runnerID=\"nUnit\" TestMethod=\"TestABC1\" TestType=\"XXX.abcTest\" Explicitly=\"false\" /><Task type=\"JetBrains.ReSharper.UnitTestProvider.nUnit.NUnitTestTask\" runnerID=\"nUnit\" TestMethod=\"TestABC2" TestType=\"XXX.abcTest\" Explicitly=\"false\" /><Task type=\"JetBrains.ReSharper.UnitTestProvider.nUnit.NUnitTestTask\" runnerID=\"nUnit\" TestMethod=\"TestABC3\" TestType=\"XXX.abcTest\" Explicitly=\"false\" /><Task type=\"JetBrains.ReSharper.UnitTestProvider.nUnit.NUnitTestTask\" runnerID=\"nUnit\" TestMethod=\"TestABC4\" TestType=\"XXX.abcTest\" Explicitly=\"false\" /><Task type=\"JetBrains.ReSharper.UnitTestProvider.nUnit.NUnitTestTask\" runnerID=\"nUnit\" TestMethod=\"TestABC5\" TestType=\"XXX.abcTest\" Explicitly=\"false\" /></TaskList></Task></TaskList>") Line 81    C#
     JetBrains.ReSharper.TaskRunnerFramework.dll!JetBrains.ReSharper.TaskRunnerFramework.TaskRunnerHostBase.ExecuteSerializedTree(string serializedTree = "<TaskList><Task type=\"JetBrains.ReSharper.UnitTestProvider.nUnit.NUnitTestFixtureTask\" runnerID=\"nUnit\" TypeName=\"XXX.abcTest\" AssemblyLocation=\"C:\\XXX\\ABC.dll\" Explicitly=\"false\"><TaskList><Task type=\"JetBrains.ReSharper.UnitTestProvider.nUnit.NUnitTestTask\" runnerID=\"nUnit\" TestMethod=\"TestABC\" TestType=\"XXX.abcTest\" Explicitly=\"false\" /><Task type=\"JetBrains.ReSharper.UnitTestProvider.nUnit.NUnitTestTask\" runnerID=\"nUnit\" TestMethod=\"TestABC1\" TestType=\"XXX.abcTest\" Explicitly=\"false\" /><Task type=\"JetBrains.ReSharper.UnitTestProvider.nUnit.NUnitTestTask\" runnerID=\"nUnit\" TestMethod=\"TestABC2\" TestType=\"XXX.abcTest\" Explicitly=\"false\" /><Task type=\"JetBrains.ReSharper.UnitTestProvider.nUnit.NUnitTestTask\" runnerID=\"nUnit\" TestMethod=\"TestABC3\" TestType=\"XXX.abcTest\" Explicitly=\"false\" /><Task type=\"JetBrains.ReSharper.UnitTestProvider.nUnit.NUnitTestTask\" runnerID=\"nUnit\" TestMethod=\"TestABC4\" TestType=\"XXX.abcTest\" Explicitly=\"false\" /><Task type=\"JetBrains.ReSharper.UnitTestProvider.nUnit.NUnitTestTask\" runnerID=\"nUnit\" TestMethod=\"TestABC5\" TestType=\"XXX.abcTest\" Explicitly=\"false\" /></TaskList></Task></TaskList>") Line 32 + 0x11 bytes    C#
     [External Code]  
     JetBrains.ReSharper.TaskRunnerFramework.dll!JetBrains.ReSharper.TaskRunnerFramework.IsolatedAppDomainHost.ExecuteNodes(System.Collections.Generic.IList<JetBrains.ReSharper.TaskRunnerFramework.TaskExecutionNode> roots = Count = Cannot evaluate expression because the code of the current method is optimized.) Line 78    C#
     JetBrains.ReSharper.TaskRunnerFramework.dll!JetBrains.ReSharper.TaskRunnerFramework.IsolatedAssemblyTaskRunner.ExecuteRecursive(JetBrains.ReSharper.TaskRunnerFramework.TaskExecutionNode node = {JetBrains.ReSharper.TaskRunnerFramework.TaskExecutionNode}) Line 44 + 0x1e bytes    C#
     JetBrains.ReSharper.TaskRunnerFramework.dll!JetBrains.ReSharper.TaskRunnerFramework.CurrentAppDomainHost.Execute(JetBrains.ReSharper.TaskRunnerFramework.TaskExecutionNode node = {JetBrains.ReSharper.TaskRunnerFramework.TaskExecutionNode}) Line 103 + 0xb bytes    C#
     JetBrains.ReSharper.TaskRunnerFramework.dll!JetBrains.ReSharper.TaskRunnerFramework.CurrentAppDomainHost.DoExecuteNodes(System.Collections.Generic.IEnumerable<JetBrains.ReSharper.TaskRunnerFramework.TaskExecutionNode> nodes = Count = Cannot evaluate expression because the code of the current method is optimized.) Line 68 + 0x32 bytes    C#
     JetBrains.ReSharper.TaskRunnerFramework.dll!JetBrains.ReSharper.TaskRunnerFramework.CurrentAppDomainHost.ExecuteNodes(System.Collections.Generic.IList<JetBrains.ReSharper.TaskRunnerFramework.TaskExecutionNode> nodes = Count = Cannot evaluate expression because the code of the current method is optimized.) Line 54    C#
     JetBrains.ReSharper.TaskRunnerFramework.dll!JetBrains.ReSharper.TaskRunnerFramework.TaskExecutor.Run(string remotingAddress = "ipc://e3e6929d-0340-4777-b244-13d7250a5d48/3da374b4-1334-408c-ac8d-f4e1165b1074;e3e6929d-0340-4777-b244-13d7250a5d48", string sessionID = "e9fbb0e1-5d15-4fba-9993-77114f75b0a9", bool isolateAssemblies = true, JetBrains.ReSharper.TaskRunnerFramework.ProxyFactoryDelegate proxyFactory = {Method = Cannot evaluate expression because the code of the current method is optimized.}) Line 87    C#
     JetBrains.ReSharper.TaskRunnerFramework.dll!JetBrains.ReSharper.TaskRunnerFramework.TaskExecutor.Run(string remotingAddress = "ipc://e3e6929d-0340-4777-b244-13d7250a5d48/3da374b4-1334-408c-ac8d-f4e1165b1074;e3e6929d-0340-4777-b244-13d7250a5d48", string sessionID = "e9fbb0e1-5d15-4fba-9993-77114f75b0a9", bool isolateAssemblies = true) Line 29    C#
     JetBrains.ReSharper.TaskRunner.exe!JetBrains.ReSharper.TaskRunner.TaskRunnerApplication.Main(string[] args = {string[2]}) Line 44 + 0x36 bytes    C#



I hope you can help since this is very annoying...

0

Hello,

This is not an exception but an MDA, which is a false alert in this case.
Currently the only way to get rid of the message is to turn off that particular
MDA.


Serge Baltic
JetBrains, Inc — http://www.jetbrains.com
“Develop with pleasure!”


0

Please sign in to leave a comment.