I think you missed my point.
I know about the interactions of managed and NGEN'ed assemblies
Just bear with me...
Let's say you start with a managed app.
The app can be NGEN'ed.
It's dependancies are also NGEN'ed.
A utility extracts the native code and generates a NEW unmanaged Windows
App.
The user runs the new app (no CLR used or needed) and never knows that it
started out life as a C# app.
It's not as crazy or impossible as you think.
The major dependancy would be S.W.F which is a pretty thin layer on GDI and
USER and COMMCTRL.
The other dependancy would be S.Drawing which is also a thin layer on
GDIplus.dll
Maybe MS doesn't like the fact that it can and will happen.
That's another argument.
It seems that they have gone out of their way to cripple NGEN'ed assemblies
but as long as there is x86 code there is really no way to prevent it.
The new app created by the utility would be large but not unusably large.
For small apps, it could be useful.
Oscar
"JKJ" <je**************@mchsi.com> wrote in message
news:05****************************@phx.gbl...
Being able to compile to native code would be nice, but
it just isn't possible with C#. It is a pure managed
language. It must run on top of the CLR within the
framework.
Even with the NGEN code, the MSIL is still deployed with
the app so dependencies and such can be worked out. From
what I understand, even though the ngen code is loaded by
the CLR and executed , the MSIL is still being
referenced. There is just no other way. To write native
code for Windows, you're going to have to resort to
another language that has a compiler that can target the
Windows platform.
Now, they do have native code compilers for Java, and
Java is designed to be a managed language, not compiled.
Maybe in the future somebody will figure out how to
design and pure native code compiler for C# that doesn't
require the framework (I wouldn't hold my breath). Who
ever may come up with one, I can guarantee you it WON'T
be from MS since they are banking so hard on the .NET
platform. Besides there are many benefits to running
managed code, but I am not the expert to list them
all. . .
-----Original Message-----
If you have an "ngen" version of an assembly and you
have the "ngen" versionof the dependant .NET classes, what is to stop you from
extracting thenative code and doing away with the runtime?
A new executable could be created with just the code
needed for the app.For small programs, this might be quite desirable.
Am I missing something?
Oscar
"JKJ" <je**************@mchsi.com> wrote in message
news:02****************************@phx.gbl... Short answer: no.
C# apps must run within the .NET framework. You can 'ngen' the assembly, but the framework must still exist on the
target machine to read all of the assembly's metadata, and the MSIL still gets deployed with the assembly
regardless. . .
Hope this clarifies things. . .
>-----Original Message-----
>Is it possible to write an unmanaged or native app in C# >the way you can with C++.NET? From a post there it was
>implied that an unmanaged app could be created simply by >not compiling it with the /clr switch. Does such a switch >exist for C#?
>Thanks
>.
>
.