473,657 Members | 2,450 Online
Bytes | Software Development & Data Engineering Community
+ 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 3203
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
741
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 managed point-of-view I've noticed that: 1) for each managed and unmanaged C function (not C++ classes) I get a public managed static method (defined on a 'Global Functions' class) in the generated assembly with an export name of the form...
2
5999
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 managed one. I have taken a look at following sample code on how to do this. http://longhorn.msdn.microsoft.com/lhsdk/ndp/vcmg_appendixs amplecode.aspx
4
39987
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 deals with managed in one place, and code that deals with unmanaged in another place, but I can't seem to find anything that clearly explains what that means. I think if I used a Windows API function to optain a handle, that handle would be an...
3
3500
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
1645
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 code which works well. I understand the basic concept: our code is unmanaged, Windows Forms is Managed and Unmanaged may not call Managed code. I read about Wrappers, PInvoke, Runtime Callable Wrappers for COM and about It just
6
1305
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 tell me how to force ASP.NET not to "clear" or reinitialize unmenaged global or static variables that are set on unmanaged level between successive requests?
6
4116
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 memory management and connection pooling constructs) as static variables which were intended to scoped to the process. 2. Managed C++ assemblies (.NET 1.1) that wrap the unmanaged DLLs as nice neat classes with managed interfaces.
9
3117
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 this, I want to use it. Is it possible to call Managed class functions from Unmanaged class? How to do it? I did something like this. I declared a managed class (in C++ CLI) called as MyManagedClass whose
5
1907
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 follows: // Unmanaged.h #pragma once namespace Unmanaged { class __declspec(dllexport) UnmanagedClass { // TODO: Add your methods for this class here.
2
12354
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 classes in managed C++ as a wrapper to the unmanaged C++ classes or is there an easier way? Essentially what I have done is written a C++ kernel mode driver and I want to use it from my C# program. Because it requires some setup outside the...
0
8742
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8518
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8621
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6177
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
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 we have to send another system
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.