Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Ngen be used for code security?

Can Ngen be used as the perfect Code Obfuscator, protecting your .NET CIL from ever reaching the client?

Can I run Ngen on my dev PC and ship the exe to every client that has a compatible .NET framework version? (assuming both are x86 or x64) What are the differences between Ngen'd exe's across machines?

I know the latest Ngen generates an exe that contains the IL + Native code, which can be extracted and "converted" back to source code using something like Reflector. However, the ngen for .NET framework 1.1 strips out the IL in the generated exe, making it a possible choice for code security if you use .NET framework 1.1.

like image 952
Robin Rodricks Avatar asked Feb 07 '26 05:02

Robin Rodricks


1 Answers

No, CLR requires IL assembly in order to locate the corresponding native image. So you would need to distribute IL binaries anyways. See this page for more info on how CLR locates Native Images: http://blogs.msdn.com/b/abhinaba/archive/2013/12/11/net-loading-native-ngen-images-and-its-interaction-with-the-gac.aspx

Besides, NGEN images are not designed to be distributed. Native image generation is tightly coupled with the machine it runs on.

like image 146
m_eric Avatar answered Feb 08 '26 20:02

m_eric