473,471 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

an unmanaged app with C#

JKJ
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
.

Nov 13 '05 #1
2 3185
If you have an "ngen" version of an assembly and you have the "ngen" version
of the dependant .NET classes, what is to stop you from extracting the
native 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
.

Nov 13 '05 #2
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" version
of the dependant .NET classes, what is to stop you from

extracting the
native 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
>.
>

.

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is visible in those assemblies from a...
2
by: Paul Kenny | last post by:
Hi, I am trying to expose the functionality of an unmanaged C++ class to the other languages available in the .NET Framework. I have decided to do this by wrapping the unmanaged C++ class in a...
4
by: Rachel Suddeth | last post by:
What is the difference between a managed/unmanaged resource, and how do you tell which is which? I'm trying to understand how to write some Dispose() methods, and we are supposed to put code that...
3
by: zhphust | last post by:
I want to convert a object of a managed class to a unmanaged structure that has the same member with that managed class. Can anybody tell me how i can do it? Thanks in advance. -- zhphust...
1
by: Sparhawk | last post by:
Hi, my company is going to migrate a large VC++ application to .NET to make use of Windows Forms (the old class library is not updated any more). We are not planning to migrate the rest of the...
6
by: marek | last post by:
Hello All, we are doing a quite a big project that contains at the lowest level an unmenaged c++ classes. Above it there are managed wrappers and at the top there are ASP.NET pages. Can anyone...
6
by: Stephen Walch | last post by:
Our application environment consists of three basic layers: 1. Third-party unmanaged DLLs that were written before the CLR was invented and maintain a significant amount of information (including...
9
by: Amit Dedhia | last post by:
Hi All I have a VC++ 2005 MFC application with all classes defined as unmanaged classes. I want to write my application data in xml format. Since ADO.NET has buit in functions available for...
5
by: akash | last post by:
I'm having problems calling an unmanaged class from a managed wrapper. I suspect I'm missing something obvious, as I'm unfamiliar with C++ and classes are very simple. My unmanaged class is as...
2
by: Jon Slaughter | last post by:
How difficult is it for one to integrate unmanaged C++ into C#? I know for functions one can use DLLimport but how does one go about doing it for classes? Do I have to completely reimplement the...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.