We are using Moles framework (0.94.5) to write unit test cases but not able to either debug or run the test cases.
System: Win7 64bit
Moles: 0.94.5 64bit with VS 2010 pro
The solution build successfully. But while trying to run test cases we are getting the following error.
{
Error
9/6/2013 3:35:32 PM
System.InvalidOperationException : Could not start Moles host. Please review the Test Run Errors for more information. //error
at Microsoft.Moles.VsHost.Agent.HostTestAdapterDriver.EnsureHostAdapter()
at //error
Microsoft.Moles.VsHost.Agent.HostTestAdapterDriver.Microsoft.VisualStudio.TestTools.Execution.IBaseAdapter.Run(ITestElement testElement, ITestContext testContext)
at Microsoft.Moles.VsHost.Agent.MolesAgentAdapter.Run(ITestElement testElement, ITestContext testContext) //error
U0319VM2184
We also followed the fuslogvw to identify if there is any error during assembly loading. It gave two errors for Moles saying
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Program Files\Microsoft Moles\bin\moles.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = NORD\x03g
LOG: DisplayName = Microsoft.Moles, Version=0.94.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Program Files/Microsoft Moles/bin/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = moles.exe
Calling assembly : moles, Version=0.94.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
}
===
LOG: Start binding of native image Microsoft.Moles, Version=0.94.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
WRN: No matching native image found.
We checked the configurations and everything seems ok. On one of the blog it was mentioned to remove the .exe.config file from privateassemblies folder under VS2010 IDE folder. But could not get it working.
After following the above the error we got is moles looking for the project dll in a different drive from where project is located.
after we uninstalled moles restarted and installed moles restarted the machine but to no avail.
Could not find the right category under which to post this.
Thanks
Vicky
+1 for research already done. It's appreciated and will get you far here.
I can add the following: You have a 64 bit machine and 64 bit moles. Are the tests you are running also 64 bit? If they are, the following solved this for me. If not, try it anyway.
AssemblyInfo.cs
file in your test project.[assembly: MolesAssemblySettings(Bitness = MolesBitness.x64)]
That was all I needed.