Staticly linked .NET Framework


I know what I’m asking is… kind of odd, but I’m in a situation where I have a .NET program written in managed C++ that needs to run on a computer with absolutely no possibility of having the framework installed proper.

Now, I’ve seen an entire Java virtual machine packaged inside a standard windows executable to be able to run one specific Java program without a JVM installed. Is this somehow possible with the .NET vm? Something akin to statically linking to the entire .NET framework? Executable size is of absolutely no concern to me as long as it fits on a CD.

Any suggestions?



I don’t believe this is a supported configuration, and it may be entirely impossible. But if I had to make it happen, I’d start by looking at side-by-side installation of the Framework. This is meant for development, and I don’t know what the licensing requirements are, but it might be a start:

Here’s the info

Sorry I can’t be of more help, I presume that you already know that unmanaged code would have been a much better choice for this app. Not that that helps you now.

I needed a windows C++ application to be developed in a few days that had a rather extensive GUI, so I grabbed the first tool I saw available. Which was managed C++ with Windows Forms. Then they tell me they can’t install .NET, wasn’t in the spec.

If I could create MFC GUI that fast I would’ve done it. sigh It’s times like these that I hate how nobody pays for Borland anymore.

Out of curiosity, do you plan to compile to .NET bytecode or native code that uses the .NET libraries? (I think C# is the only .NET language that ‘officially’ supports native code compilation, but I could be wrong.)

As for GUI building: There are plenty of ways to build a Windows GUI without .NET. wxWidgets comes to mind. If there’s a way to change the tool you’re using, it seems wxWidgets defaults to being statically-linked and, therefore, saves you the hassle of dealing with DLLs.

Derleth: All the .NET languages can be compiled to bytecode. The compiler which does it (NGEN.exe) takes MSIL in & produces raw machine code. Which .NET language was used to produce the MSIL is immaterial.

It’s also the case that much of the Framework itself is installed as bytecode. Take a look in C:\Windows\Assembly at the Processor Architecture column.
OP: If you can’t install the Framework, you can’t install the Framework. It’s waay too deep to try to statically link, and it depends on files, users, folder trees, services, registry entries, and all sorts of other ancillary BS that must be present for the CLR DLLs to run successfully. Linking in the DLLs is the least of your needs.

Thank you. I certainly wasn’t planning on doing it by hand, I was hoping Microsoft already had a solution just like Java does, but apparently it does not. So, I’ll try to come up with some alternative.

At my shop we use Delphi 7 for situations like this. Easy to generate the UI and strong Win32 API support.

How big is the code base? If it’s C++, a port to Java might be doable in fairly short order; you’d have to use Swing/AWT/WidgetSetOfTheMonth, but you could probably reclaim some of the code.

Alternatively, you could reimplement in Visual Basic 6; this is the opposite tradeoff; you could reclaim (or at least quickly reimplement) the forms stuff, but you’d lose the rest of the app. You’d still have to install VB6 runtimes, but they might already be there (and in any case they’re much smaller).

Or if you don’t want to rewrite at all…VMWare Server is free: You could install a VIRTUAL Windows XP with .NET installed, which wouldn’t alter the base configuration of the machine at all. You’d need a ton of disk space, and performance might suffer, but if it’s a Win Forms app, performance probably isn’t a big deal anyway. Whether this is viable depends on a lot of things, I suppose.

We are seriously considering either this option or just insisting that .NET framework is installed.

Have you looked into these?

Salamander .NET Linker and Mini-Deployment Tool

DotGNU Portable .NET

Hey, that first one on Reply’s list looks like it’s just what you want.

The DOTGNU stuff is a Mono wrapper (I think), which is the other thing that occurred to me last night – replace .NET itself with something like Mono (an open source .NET clone).