Statically Link DLL to CLR Console App?


Hi all;

I am trying to create a managed CLR console app that is "self-contained",
that can be run without having to install anything, and I've run into a
bit of a situation.

It would seem that, even though I've specified a "pure" clr build, some
unmanaged DLL's are being utilized within that build anyway. When I create
a CLR Console App project, build it, then port the resulting executable over
to a system that does not have the .NET framework installed (a system
running Windows 2000 in this case), I get the following error message:
======================================================================
Unhandled Exception: System.TypeInitializationException: The type initializer
for '<Module>' threw an exception.
---> System.DllNotFoundException: Unable to load DLL 'msvcm90d.dll':
The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at <CrtImplementationDetails>.ThrowModuleLoadException(String , Exception )
at <CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* )
at .cctor()
--- End of inner exception stack trace ---
======================================================================



One thing that I want to mention is that, in creating that project, I did
nothing to it. I left it "as is" - Console::WriteLine(L"Hello World"); in main.
I created the project to demonstrate the nature of the problem, and the
problem is not with my code, nor with anything that I am doing.

I thought that maybe if I tried to disable language extensions, it might not
reference the DLL, but no luck with that.

On building, I get the following:
Command line error 8016: options '/Za' and '/clr:pure' are not compatible.

I tried to change the Run-time library from "Multi-threaded DLL" (/MD)
to "Multi-threaded" (/MT), but that won't work either. On compilation,
I get:
/MTd and /clr:Pure are incompatible

I must compile with /MD (or /MDd) with clr option
(/MD => "Multi-threaded DLL").

Apparently, this is where I am getting the (unmanaged) msvcm90d.dll.

I've been trying to figure out how to statically link that library to
the executable, but I've not found anything that tells me explicitly
how to do that.

I tried adding "/FU msvcm90d.dll" to the command line for compilation,
but that didn't do me any good.

I've also tried #include "msvcm90d.dll", with no effect.

This is where I need some help.

How do I statically link that DLL to the build/executable?

Any other comments or suggestions would be appreciated.

Thanks!!!

Topic archived. No new replies allowed.