Managed Code in Visual Studio

Is it possible to disable managed code (and enable unmanaged code) for C ++ coding so that programs (exes) run directly on native native code in Visual Studio 2008?

Also, is it true that after the first run of an exe.net (managed) exe (like written in C #) the exe gets converted to native code (like old C ++ - pre.net)? Or is there a way to get it to compile directly into native code if written in C #?

+2


source to share


3 answers


The answer to both of these questions is yes.

You can create unmanaged C ++ code projects in VS that are not needed by .Net. You can also bundle unmanaged C ++ code with managed C ++ code and (sort of) get the best of both worlds - although the mapping of call parameters between systems is interesting.

You can also use the ngen.Net utility to precompile .NET projects to clean code. However, you lose some flexibility when doing this. The JIT compiler will consider local capabilities when compiling a .Net project. So if you distribute a .Net project generated by VS then ngen on the local machine that runs the program will compile. However, if you are using ngen on your machine, the precompiled code will be tied to the processsor capabilities of your system.



As Joel says. whether using ngen or not, you still need the .Net framework on the target machine.

With that in mind, using ngen to pre-compile a .Net project is probably no worse than compiling an unmanaged C ++ project into native code.

+4


source


To do what you want for C #, you would use ngen.exe that comes with the C # compiler. You run this command in the image and it is added to the GAC as native code.



+1


source


As far as I know, you can temporarily switch to unmanaged code, i.e. using unmanaged variables, etc. by marshaling. Take a look here: http://msdn.microsoft.com/de-de/library/bb384865.aspx

0


source







All Articles