BadImageFormatException on load of nmapi.dll from MSTEST RRS feed

  • Question

  • I am running a test in MSTEST which requires some network monitoring. Until now, my code was working perfectly but a few days ago, I began to get BadImageFormatException on the call to NmOpenCaptureEngine (in NetMonApi.cs).

    The problem seems to be that MSTEST which runs inside Visual Studio 2012 must run in 32 bit mode whereas my system is 64 bit. My system has Network Monitor 64 bit installed. In order to make it work previously, I downloaded the 32 bit version and extracted the nmapi.dll from there and placed it in the bin directory of the Visual Studio project. What seems to be happening is that the test is ignoring the 32 bit version in the bin directory and taking the 64 bit version installed on the machine. The reason I think this is because if I uninstalled the network monitor from my system, it can no longer find the dll even though it's right there in the bin directory. 

    I tried copying the 32 bit dll to the bin directory of the test project itself and get the same results.

    As I said, this was working just fine until a few days (maybe weeks?) ago. Any help will be appreciated.

    Here is the stack trace:

    System.BadImageFormatException was unhandled by user code
      Message=An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
           at Microsoft.NetworkMonitor.NetmonAPI.NmOpenCaptureEngine(IntPtr& phCaptureEngine)
           at Viewbix.NetworkMonitor.TrafficCapturer.Start(IEnumerable`1 adapters) in d:\Azure\Viewbix.NetworkMonitor\TrafficCapturer.cs:line 51
           at Viewbix.Testing.Selenium.Screens.PlayerHosts.AffiliateLandingPage.TestRedirect() in d:\Azure\Viewbix.Testing.Selenium\Screens\PlayerHosts\AffiliateLandingPage.cs:line 27
           at Viewbix.Testing.Selenium.ViewbixTests.AffiliateRedirectTest() in d:\Azure\Viewbix.Testing.Selenium\ViewbixTests.cs:line 96

    Monday, December 2, 2013 9:40 AM

All replies

  • I'm not sure I can help because I believe this issue is not specific to Network Monitor, but rather how the OS is finding the DLL.  Maybe modifying the path and putting the 32bit version first might help, but you might find more help in one of the OS specific forums.


    Thursday, December 5, 2013 3:04 PM