Unit testing throws many BadImageFormatException

This is all being done in VS 2008 Development Edition.

First note: Launching my application in the debugger (not as a test, a normal execution of the application) does not result in these exceptions.

I noticed when writing several test cases that the tests seemed to take a long time to even START running (sat in "Pending" forever), more so than I remember them doing in the past.

I selected to Debug a test case, and saw in the Output window was just spewing with BadImageFormatExceptions.  Over and over and over.  I would guess the number is actually up near 50-60.  I setup the debugger to break anytime a BadImageFormatException was thrown and it is the following:
Could not load file or assembly 'C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\symsrv.dll' or one of its dependencies. The module was expected to contain an assembly manifest.

I can hit continue and get a new DLL name, all of them seemingly within that PrivateAssemblies folder.  Last time I ran into a BadImageFormatException, it was something to do with 32-bit vs 64-bit.  I am on a 64-bit machine (Windows 7), all projects in this solution are set to "Any CPU" as the Platform Target.

The call stack at the time of one of these exceptions looks like:

     mscorlib.dll!System.Reflection.AssemblyName.GetAssemblyName(string assemblyFile) + 0x52 bytes    
     JetBrains.ReSharper.TaskRunnerFramework.dll!JetBrains.ReSharper.TaskRunnerFramework.AssemblyLoader.ResolveAssemblyFileByName(string name = "Microsoft.VisualStudio.QualityTools.LoadTest, PublicKeyToken=b03f5f7f11d50a3a", bool isFullName = true) Line 173 + 0x8 bytes    C#
     JetBrains.ReSharper.TaskRunnerFramework.dll!JetBrains.ReSharper.TaskRunnerFramework.AssemblyLoader.ResolveAssembly(object sender = {Name:IsolatedAppDomainHost: D:\AccuRev\Lonestar_3.1_Component_Testing\SourceCode\TSS2\Driver\LoopDriver\LoopDriverTests\bin\Debug\LoopDriverTests.dll
There are no context policies.
}, System.ResolveEventArgs args = {System.ResolveEventArgs}) Line 107 + 0xd bytes    C#
     mscorlib.dll!System.AppDomain.OnAssemblyResolveEvent(string assemblyFullName = "Microsoft.VisualStudio.QualityTools.LoadTest, PublicKeyToken=b03f5f7f11d50a3a") + 0x82 bytes    
     [Native to Managed Transition]    
     [Managed to Native Transition]    
     mscorlib.dll!System.RuntimeTypeHandle.GetTypeByName(string name, bool throwOnError, bool ignoreCase, bool reflectionOnly, ref System.Threading.StackCrawlMark stackMark) + 0x41 bytes    
     mscorlib.dll!System.RuntimeType.PrivateGetType(string typeName, bool throwOnError, bool ignoreCase, bool reflectionOnly, ref System.Threading.StackCrawlMark stackMark) + 0x3b bytes    
>    mscorlib.dll!System.Type.GetType(string typeName, bool throwOnError) + 0x3c bytes    
     Microsoft.VisualStudio.QualityTools.Common.dll!Microsoft.VisualStudio.TestTools.Common.Xml.XmlElementToClassMapping.TryAddBuiltInType(string elementName = "WebTestRunConfiguration", string requestedType = "Microsoft.VisualStudio.TestTools.WebStress.WebTestRunConfig, Microsoft.VisualStudio.QualityTools.LoadTest, PublicKeyToken=b03f5f7f11d50a3a", System.Type substituteType = null) + 0x29 bytes    
     Microsoft.VisualStudio.QualityTools.Common.dll!Microsoft.VisualStudio.TestTools.Common.Xml.XmlElementToClassMapping.LoadBuiltInTypes() + 0x4f bytes    
     Microsoft.VisualStudio.QualityTools.Common.dll!Microsoft.VisualStudio.TestTools.Common.Xml.XmlElementToClassMapping.XmlElementToClassMapping() + 0x91 bytes    
     Microsoft.VisualStudio.QualityTools.Common.dll!Microsoft.VisualStudio.TestTools.Common.Xml.XmlElementToClassMapping.Mapping.get() + 0x31 bytes    
     Microsoft.VisualStudio.QualityTools.Common.dll!Microsoft.VisualStudio.TestTools.Common.Xml.XmlLoader.GetKnownSchemas() + 0x82 bytes    
     Microsoft.VisualStudio.QualityTools.Common.dll!Microsoft.VisualStudio.TestTools.Common.Xml.XmlLoader.Schemas.get() + 0x21 bytes    
     Microsoft.VisualStudio.QualityTools.Common.dll!Microsoft.VisualStudio.TestTools.Common.Xml.XmlLoader.LoadAndValidate(string source = "D:\\AccuRev\\Lonestar_3.1_Component_Testing\\SourceCode\\TSS2\\Driver\\LoopDriver\\LocalTestRun.testrunconfig", System.Xml.XmlReader reader = {None}) + 0x96 bytes    
     Microsoft.VisualStudio.QualityTools.Common.dll!Microsoft.VisualStudio.TestTools.Common.Xml.XmlLoader.Load(string source = "D:\\AccuRev\\Lonestar_3.1_Component_Testing\\SourceCode\\TSS2\\Driver\\LoopDriver\\LocalTestRun.testrunconfig", System.Xml.XmlReader reader = {None}) + 0x3a bytes    
     Microsoft.VisualStudio.QualityTools.Common.dll!Microsoft.VisualStudio.TestTools.Common.Xml.XmlFilePersistence.LoadFile(string fileName = "D:\\AccuRev\\Lonestar_3.1_Component_Testing\\SourceCode\\TSS2\\Driver\\LoopDriver\\LocalTestRun.testrunconfig") + 0xfa bytes    
     Microsoft.VisualStudio.QualityTools.Common.dll!Microsoft.VisualStudio.TestTools.Common.Xml.XmlFilePersistence.LoadTestRunConfiguration(string fileName = "D:\\AccuRev\\Lonestar_3.1_Component_Testing\\SourceCode\\TSS2\\Driver\\LoopDriver\\LocalTestRun.testrunconfig") + 0x34 bytes    
     Microsoft.VisualStudio.QualityTools.TMI.dll!Microsoft.VisualStudio.TestTools.TestManagement.Tmi.LoadRunConfiguration(string storage = "D:\\AccuRev\\Lonestar_3.1_Component_Testing\\SourceCode\\TSS2\\Driver\\LoopDriver\\LocalTestRun.testrunconfig", Microsoft.VisualStudio.TestTools.TestManagement.Tmi.RunConfigurationConflictHandler vetoingHandler = {Method = {ConflictAction DefaultRunConfigurationConflictHandler(Microsoft.VisualStudio.TestTools.Common.TestRunConfiguration, Microsoft.VisualStudio.TestTools.Common.TestRunConfiguration)}}) + 0xa6 bytes    
     Microsoft.VisualStudio.QualityTools.TMI.dll!Microsoft.VisualStudio.TestTools.TestManagement.Tmi.LoadRunConfiguration(string storage = "D:\\AccuRev\\Lonestar_3.1_Component_Testing\\SourceCode\\TSS2\\Driver\\LoopDriver\\LocalTestRun.testrunconfig") + 0x4b bytes    
     Microsoft.VisualStudio.QualityTools.CommandLine.dll!Microsoft.VisualStudio.TestTools.CommandLine.TmiAdapter.LoadRunConfig() + 0x95 bytes    
     Microsoft.VisualStudio.QualityTools.CommandLine.dll!Microsoft.VisualStudio.TestTools.CommandLine.RunConfigCommand.Execute(Microsoft.VisualStudio.TestTools.CommandLine.TmiAdapter tmi = {Microsoft.VisualStudio.TestTools.CommandLine.TmiAdapter}) + 0x8c bytes    
     Microsoft.VisualStudio.QualityTools.CommandLine.dll!Microsoft.VisualStudio.TestTools.CommandLine.Executor.Execute() + 0x22b bytes    
     [Native to Managed Transition]    
     [Managed to Native Transition]    
     JetBrains.ReSharper.UnitTestProvider.MSTest.dll!JetBrains.ReSharper.UnitTestProvider.MSTest.MSTestTaskRunnerRecursive.RunTests(JetBrains.ReSharper.UnitTestProvider.MSTest.MsTestTestAssemblyTask task = {JetBrains.ReSharper.UnitTestProvider.MSTest.MsTestTestAssemblyTask}) Line 199 + 0x50 bytes    C#
     JetBrains.ReSharper.UnitTestProvider.MSTest.dll!JetBrains.ReSharper.UnitTestProvider.MSTest.MSTestTaskRunnerRecursive.ExecuteRecursive(JetBrains.ReSharper.TaskRunnerFramework.TaskExecutionNode node = {JetBrains.ReSharper.TaskRunnerFramework.TaskExecutionNode}) Line 87    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 = 0x00000001) Line 68 + 0x32 bytes    C#
     JetBrains.ReSharper.TaskRunnerFramework.dll!JetBrains.ReSharper.TaskRunnerFramework.CurrentAppDomainHost.ExecuteNodes(System.Collections.Generic.IList<JetBrains.ReSharper.TaskRunnerFramework.TaskExecutionNode> nodes = Count = 0x00000001) Line 54    C#
     JetBrains.ReSharper.TaskRunnerFramework.dll!JetBrains.ReSharper.TaskRunnerFramework.TaskRunnerHostBase.ExecuteSerializedTree(string serializedTree = "<TaskList><Task type=\"JetBrains.ReSharper.UnitTestProvider.MSTest.MsTestTestAssemblyTask\" runnerID=\"MSTest\" AssemblyLocation=\"D:\\AccuRev\\Lonestar_3.1_Component_Testing\\SourceCode\\TSS2\\Driver\\LoopDriver\\LoopDriverTests\\bin\\Debug\\LoopDriverTests.dll\" RunConfigurationFilename=\"D:\\AccuRev\\Lonestar_3.1_Component_Testing\\SourceCode\\TSS2\\Driver\\LoopDriver\\LocalTestRun.testrunconfig\"><TaskList><Task type=\"JetBrains.ReSharper.UnitTestProvider.MSTest.MsTestTestClassTask\" runnerID=\"MSTest\" TypeName=\"LoopDriverTests.NaztecProtocolGenerationTests\" AssemblyLocation=\"D:\\AccuRev\\Lonestar_3.1_Component_Testing\\SourceCode\\TSS2\\Driver\\LoopDriver\\LoopDriverTests\\bin\\Debug\\LoopDriverTests.dll\"><TaskList><Task type=\"JetBrains.ReSharper.UnitTestProvider.MSTest.MsTestTestMethodTask\" runnerID=\"MSTest\" TestMethod=\"PollMessageTest\" TestType=\"LoopDriverTests.NaztecProtocolGenerationTests\" AssemblyLocation=\"D:\\AccuRev\\Lonestar_3.1_Component_Testing\\SourceCode\\TSS2\\Driver\\LoopDriver\\LoopDriverTests\\bin\\Debug\\LoopDriverTests.dll\" /></TaskList></Task></TaskList></Task></TaskList>") Line 33    C#
     [Appdomain Transition]    
     JetBrains.ReSharper.TaskRunnerFramework.dll!JetBrains.ReSharper.TaskRunnerFramework.IsolatedAppDomainHost.ExecuteNodes(System.Collections.Generic.IList<JetBrains.ReSharper.TaskRunnerFramework.TaskExecutionNode> roots = Count = 0x00000001) 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 = 0x00000001) Line 68 + 0x32 bytes    C#
     JetBrains.ReSharper.TaskRunnerFramework.dll!JetBrains.ReSharper.TaskRunnerFramework.CurrentAppDomainHost.ExecuteNodes(System.Collections.Generic.IList<JetBrains.ReSharper.TaskRunnerFramework.TaskExecutionNode> nodes = Count = 0x00000001) Line 54    C#
     JetBrains.ReSharper.TaskRunnerFramework.dll!JetBrains.ReSharper.TaskRunnerFramework.TaskExecutor.Run(string remotingAddress = "ipc://836fc90d-41b6-4586-b304-f93430588260/0af55f9e-0f9d-4ed7-a5f5-9e94f8c1d8cf;836fc90d-41b6-4586-b304-f93430588260", string sessionID = "27efb353-610c-4087-854b-993ce475c1ec", bool isolateAssemblies = true, JetBrains.ReSharper.TaskRunnerFramework.ProxyFactoryDelegate proxyFactory = {Method = {JetBrains.ReSharper.TaskRunnerFramework.IRemoteTaskServer <Run>b__0(JetBrains.ReSharper.TaskRunnerFramework.IRemoteTaskChannel, System.String)}}) Line 87    C#
     JetBrains.ReSharper.TaskRunnerFramework.dll!JetBrains.ReSharper.TaskRunnerFramework.TaskExecutor.Run(string remotingAddress = "ipc://836fc90d-41b6-4586-b304-f93430588260/0af55f9e-0f9d-4ed7-a5f5-9e94f8c1d8cf;836fc90d-41b6-4586-b304-f93430588260", string sessionID = "27efb353-610c-4087-854b-993ce475c1ec", bool isolateAssemblies = true) Line 29    C#
     JetBrains.ReSharper.TaskRunner.exe!JetBrains.ReSharper.TaskRunner.TaskRunnerApplication.Main(string[] args = {string[0x00000002]}) Line 44 + 0x36 bytes    C#


Based on the parameters, the assembly in question seems to be Microsoft.VisualStudio.QualityTools.LoadTest.  So, why would Resharper then try to load a non-.NET DLL (such as symsrv.dll)?  That I believe is the trigger for the exception (symsrv.dll not being a .NET DLL).  Any ideas?

Thanks!

6 comments
Comment actions Permalink

Thanks for your feedback, we're working on 64bit support in Unit Tests. There're still some problems with Any CPU configuration.

0
Comment actions Permalink

Hmm, based on that I went through and changed every project in the solution to be an x86 build rather than "Any CPU".  Did a rebuild on the solution, then debugged into the unit test - same result, so this does not seem to be related to the "Any CPU" that was originally selected.

0
Comment actions Permalink

Very interesting. I'll investigate your stack trace later.

Thanks again.

0
Comment actions Permalink

Sure, let me know if I can provide any other information.

Also, the test cases do seem to actually RUN with no problems, just with a bit of a delay.

0
Comment actions Permalink

Hi, Adam!

Which version of ReSharper do you use? Does this exception appear in latest 5.0 nightly builds?

0
Comment actions Permalink

I have not yet tried one of the 5.0 builds.  This is using 4.5.1288.2 (believe it is the latest 4.5 release).  I can try to get an install of 5.0 going next week and see what results that gives.

0

Please sign in to leave a comment.