All tests fail, cannot get the type and FileNotFoundException if a specific line of code in one test after adding fmod Visual C ++ test

I found out what caused the problem, but I still don’t know why this happened when I started using it fmod, and it should have something to do with how the linker decides to connect and execute static libraries and .dll. My test code is a static library; it refers to fmodex_vc, another static lib, which at some point (although I don't know when) decides to load in itsfmodex.dll. (Which is in the same directory as everything else, so I don’t know why it will not find it.) As far as I know, the code under test does not call the fmod initialization function at all, but perhaps fmod has some static global initializers that initialize themselves and load in dll? And this code only retracts if the code in the module that uses it is used ...?

I test unmanaged C ++ code using the Visual Studio test environment, and when I started using fmod, it stopped working: every test, even a “test” test that does nothing, will report (wrapped for readability):

Unable to get type SlidersTest.UnitTest1, SlidersTest.
    Error: System.IO.FileNotFoundException: 
    The specified module could not be found.
    (Exception from HRESULT: 0x8007007E)

After a lot of trial and error, excluding files .cppand re-adding them, I found that only one of the test files was causing the problem; and this only happens if this line is called:

EntityMgr::Init();

Interestingly, all tests fail with this message if this line is in the code. EntityMgr::Init()is a function that is very small:

EntityMgr* EntityMgr::instG = null;

and

void EntityMgr::Init()
{
   instG = new EntityMgr;
}

and

class EntityMgr
{
private:
   static EntityMgr* instG;
public:
   EntityMgr()   // does nothing beyond the default 
   {
   }

   static void Init();
   static EntityMgr* Inst() { return instG; }

   ...

   vector<Entity> entitiesG;
};

Entity, FWIW, is a pretty vanilla class with no pointers, just different floatfor its fields.

  • Regardless of how I run the tests (from the test view, run the selected one, run everything, run from the command line from the test menu), I get an error message.
  • - , . .
  • .lib. CLR /clr.
  • , : Entity, . , . , , .

, - :

First-chance exception at 0x7c812aeb in vstesthost.exe: Microsoft C++ exception: HRException at memory location 0x05129890..

, . :

     kernel32.dll!7c812aeb()    
    [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]  
    kernel32.dll!7c812aeb()     
    [External Code] 
    msvcr80.dll!78158ed7()  
    msvcr80.dll!78158e34()  
    msvcr80.dll!78158047()  
    msvcr80.dll!7815850e()  
    msvcr80.dll!78158872()  
    msvcr80.dll!78158a57()  
    msvcr80.dll!78158b11()  
    ntdll.dll!7c9032a8()    
    ntdll.dll!7c90327a()    
    ntdll.dll!7c92a9ef()    
    ntdll.dll!7c90e46a()    
    kernel32.dll!7c812aeb()     
    kernel32.dll!7c812aeb()     
    kernel32.dll!7c812aeb()     
    msvcr80.dll!78139c4d()  
    msvcr80.dll!781323ff()  
    msctf.dll!74755764()    
    msctf.dll!74721557()    
    ws2_32.dll!71ab12bb()   
    ntdll.dll!7c90118a()    
    ntdll.dll!7c91b084()    
    ntdll.dll!7c90de7c()    
    ntdll.dll!7c90d04c()    
    ntdll.dll!7c90e43f()    
    kernel32.dll!7c80b713()     

, mestest - .

Unable to get type SlidersTest.game_EntityMgr_test, SlidersTest. Error: System.IO.FileNotFoundException: The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
   at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, StackCrawlMark& stackMark)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestExecuter.GetType(UnitTestElement unitTest, String type)
   at Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestExecuter.ResolveMethods().

fmod ?

+3
7

(http://www.dependencywalker.com/). DLL EXE - , File Not Found - , FMod.

, Dependency Walker . .

+1

, - ? , , , " " Visual Studio.

0

, , , , - CLR - , , , GAC, .

? , .

0

, , , . , , , ( , )

0

Visual Studio , , ?

, .dll, DLL, , (). Visual Studio , , .

0

FMod.dll ? , , mstest , ? , " " . - , , .

0

I ran it in the debugger and checked the run output - in particular, the line "load path \ fmodex.dll" to see if it loads the correct DLL.

I saw similar errors when mixing dll from different configurations.

0
source

Source: https://habr.com/ru/post/1706192/


All Articles