Archived

This topic is now archived and is closed to further replies.

C# question

This topic is 4951 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Does a C# have to be compiled to run on the CLR/.NET Framework? Is there anyway to write a C# program to be independant, and run as a standard executable, the same way a C++ program is written? I understand this defeats much of the purpose for using C#, but just out of curiosity, is it possible? Thanks~! -- master_ball -- ------------------------------ What?! I can''t spell, I''m a CS major!

Share this post


Link to post
Share on other sites
quote:
Original post by master_ball
I understand this defeats much of the purpose for using C#,
but just out of curiosity, is it possible?


It''s possible, sort of: http://www.remotesoft.com/linker/



--
AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.
[Project site] [Blog] [RSS] [Browse the source] [IRC channel]

Share this post


Link to post
Share on other sites
I think that once you run a regular C# program the first time, the just-in-time compiler will compile it to a native .exe for your CPU and when you run it the second time it will just be a normal .exe.

Share this post


Link to post
Share on other sites
quote:
Original post by Matei
I think that once you run a regular C# program the first time, the just-in-time compiler will compile it to a native .exe for your CPU and when you run it the second time it will just be a normal .exe.

That doesn''t solve the deployment problem. I got the impression that was what the OP was most concerned about.

Share this post


Link to post
Share on other sites
You can just distribute it as an exe but of course the .NET framework needs to be installed already. This will be integrated into the next version of Windows.

Share this post


Link to post
Share on other sites
quote:
Original post by Matei
I think that once you run a regular C# program the first time, the just-in-time compiler will compile it to a native .exe for your CPU and when you run it the second time it will just be a normal .exe.


No, it won''t.

Running it does not change the .exe in the slightest. If the compiler makes native code out of it (which it does by default, I believe), it will store it in memory (possibly even in a cache on disc), but it won''t affect the original .exe

And next time you run it, it will likely need to do it again (unless it has some kind of cache).

Believe me, this is a feature, not a bug.

If it is subsequently run on a different platform (win64, WinCE for instance, or even a non M$ platform), then the compiler there (if it has one), will compile it differently for its own CPU.

In any case even if you could make a native .exe, that would not remove the dependency on the large .NET framework which must be installed separately.

Mark

Share this post


Link to post
Share on other sites