Search code examples
.netvisual-c++c++-cli.net-assembly

How to know which version of VC++ runtime is required by a C++/CLI assembly?


I have a C++/CLI assembly and it somehow needs msvcr120.dll (which is part of VC++ redistributable package 2013) to run. I discovered this by using tools to monitor which files the process is trying to load during running. Is there a way to get the required VC++ runtime version by looking into the dll and without running it? I tried to use ildasm.exe to look at the metadata but did not find relavant information.

Any suggestions? Thanks a lot.


Solution

  • If it's a mixed module (/clr), then the C Runtime will show up in its load-time dependencies:

    dumpbin /dependents mymodule.dll
    

    If it's a pure module (/clr:pure), then calls into the C Runtime will be via P/Invoke. You can disassemble the module and search for P/Invoke wrappers:

    ildasm /text mymodule.dll | findstr pinvokeimpl
    

    This will list the modules that may be dynamically loaded to satisfy P/Invoke calls. If the module depends on a C Runtime, you'll see it show up numerous times (you can further filter the list by searching for "msvcr" or "msvcp" if you're specifically interested in the Visual C++ libraries).