Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / October 2006

Tip: Looking for answers? Try searching our database.

Compiling .NET assembly to equivalent native code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
LOST - 21 Oct 2006 12:43 GMT
I need to compile .NET assembly to native code. Microsoft's utility
NGEN does not produce an executable file. Instead of this, it places
the precached image to WinDir\Prefetch.This image is not a PE file.
I need the one producing PE or equivalent code in C or C++ native. Can
anybody help?
Michael Nemtsev - 21 Oct 2006 13:48 GMT
Hello LOST,

L> I need to compile .NET assembly to native code.

What do u mean? Do u want to get pure unmanaged code from managed sources?
it's impossible

L> Microsoft's utility NGEN does not produce an executable file. Instead
of this, it places
L> the precached image to WinDir\Prefetch.This image is not a PE file.

Yep, NGEN gives u platform-compiled version of your app, to avoid compilation
during starting application. The reason - to improve start up time, avoid
IL compilation

L> I need the one producing PE or equivalent code in C or C++ native.

.NET apps has the PE, but it comprises shrim class that responsible for starting
app under .net framework

---
WBR,
Michael  Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
LOST - 21 Oct 2006 15:10 GMT
> Hello LOST,
>
> L> I need to compile .NET assembly to native code.
>
> What do u mean? Do u want to get pure unmanaged code from managed sources?
> it's impossible
impossible? Actually, I need almost the same code JIT compiler produce,
but stored in separate executable. Why is it impossible?
Michael Nemtsev - 21 Oct 2006 16:30 GMT
Hello LOST,

Such is the .NET architecture.

Executable is only the assembly (in case of EXE file) that has a standard
PE hearder. And that uses unmanaged mscoree.dll to init all work to start
you managed code.
NGEN there helps to avoid compilation - when u call smth u redirected to
the NGEN image not to process of JIT compilation

L> Michael Nemtsev wrote:
L>
>> Hello LOST,
>>
>> L> I need to compile .NET assembly to native code.
>>
>> What do u mean? Do u want to get pure unmanaged code from managed
>> sources? it's impossible

L> impossible? Actually, I need almost the same code JIT compiler
L> produce, but stored in separate executable. Why is it impossible?
L>
---
WBR,
Michael  Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsch
Francois PIETTE - 21 Oct 2006 16:31 GMT
>> L> I need to compile .NET assembly to native code.

>> What do u mean? Do u want to get pure unmanaged code from managed
>> sources?
>> it's impossible

> impossible? Actually, I need almost the same code JIT compiler produce,
> but stored in separate executable. Why is it impossible?

Because this code need the .NET runtime. Actually .NET is another operating
system than the underlaying OS (win32).

If you need native code, you should consider rewriting your application as a
win32 application.

Signature

Francois PIETTE
http://www.overbyte.be

LOST - 22 Oct 2006 10:49 GMT
Indeed, I understand JIT-compiled code requires runtime to execute.
I found one solution. It's Salamander. But it costs about $1200.
Michael Nemtsev - 22 Oct 2006 11:46 GMT
Hello LOST,

L> Indeed, I understand JIT-compiled code requires runtime to execute. I
L> found one solution. It's Salamander. But it costs about $1200.

Salamander is Decompiler - it just takes your managed binary and decomplile
it to the managed source code
There is nothig about "get unmanaged binary from managed source"

---
WBR,
Michael  Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
PS - 22 Oct 2006 14:40 GMT
> Hello LOST,
>
[quoted text clipped - 4 lines]
> decomplile it to the managed source code
> There is nothig about "get unmanaged binary from managed source"

<quote>
Our protector is not an obfuscator, rather it converts the decompilable
Microsoft Intermediate Language code (MSIL or CIL) of your assemblies into
native format while keeping all .NET metadata intact, and thus it provides
the same level of protection as native C/C++ code.
</quote>

It's $1899 by the way. Xenocode also have something called PostBuild
(www.xenocode.com).

PS

> ---
> WBR,
> Michael  Nemtsev :: blog: http://spaces.live.com/laflour
>
> "At times one remains faithful to a cause only because its opponents do
> not cease to be insipid." (c) Friedrich Nietzsche
Mattias Sjögren - 22 Oct 2006 17:36 GMT
>Microsoft's utility
>NGEN does not produce an executable file. Instead of this, it places
>the precached image to WinDir\Prefetch.

NGEN has nothing to do with Windows' Prefetch feature. The NGEN cache
is located in %WINDIR%\assembly\NativeImages<version> directories.

Mattias

Signature

Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

John - 23 Oct 2006 16:57 GMT
> I need to compile .NET assembly to native code. Microsoft's utility
> NGEN does not produce an executable file. Instead of this, it places
> the precached image to WinDir\Prefetch.This image is not a PE file.
> I need the one producing PE or equivalent code in C or C++ native. Can
> anybody help?

I hear you; I wanted something like this too at one time.  But for one
thing the jitter can change the executed binary code around while the
program is running in order to optimize it, so the whole idea of what
you want is impossible because the code the jitter generates can depend
on the context of the execution which would not be known if you wanted
something to generate code.

It might be possible for somebody to create a program that would take an
assembly and generate a native executable from that, but as far as I
know there is nothing like that on the market today.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.