Use NGEN with WebDeployment
-
Hello, I'm using WebDeployment to deploy (to install) an intranet web application. I compile all aspx.cs class to one DLL. I have 2 more DLL that are personal libray and that are used by my application. So, I have actually 3 DLL. I would like to use NGEN to create DLL in native code during project installation. NGEN INSTALL MYDLL1.DLL NGEN INSTALL MYDLL2.DLL NGEN INSTALL MYDLL3.DLL Could you tell me how to use NGEN with WebDeployment Project to register my three DLL ? Have I to add command line in project file (XML) - witch section ? Second point: I would like also to use Dotfuscator community 3.0 with WebDeployment - if you have an article on the subject it would be great ! I have tried by when method are renamed to aa, bb, cc. the application don't found anymore the methods of my project... :( Regards,
La Richesse & la Gloire ne griseront jamais que les temples
-
Hello, I'm using WebDeployment to deploy (to install) an intranet web application. I compile all aspx.cs class to one DLL. I have 2 more DLL that are personal libray and that are used by my application. So, I have actually 3 DLL. I would like to use NGEN to create DLL in native code during project installation. NGEN INSTALL MYDLL1.DLL NGEN INSTALL MYDLL2.DLL NGEN INSTALL MYDLL3.DLL Could you tell me how to use NGEN with WebDeployment Project to register my three DLL ? Have I to add command line in project file (XML) - witch section ? Second point: I would like also to use Dotfuscator community 3.0 with WebDeployment - if you have an article on the subject it would be great ! I have tried by when method are renamed to aa, bb, cc. the application don't found anymore the methods of my project... :( Regards,
La Richesse & la Gloire ne griseront jamais que les temples
Merlin Tintin wrote:
I would like to use NGEN to create DLL in native code during project installation.
Why do you want to do this? There are very specific reasons for deploying NGEN'd assemblies and specific problems they solve. It's not a general purpose "hammer".
Scott Dorman
Microsoft® MVP - Visual C# | MCPD President - Tampa Bay IASA [Blog][Articles][Forum Guidelines]
Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
-
Hello, I'm using WebDeployment to deploy (to install) an intranet web application. I compile all aspx.cs class to one DLL. I have 2 more DLL that are personal libray and that are used by my application. So, I have actually 3 DLL. I would like to use NGEN to create DLL in native code during project installation. NGEN INSTALL MYDLL1.DLL NGEN INSTALL MYDLL2.DLL NGEN INSTALL MYDLL3.DLL Could you tell me how to use NGEN with WebDeployment Project to register my three DLL ? Have I to add command line in project file (XML) - witch section ? Second point: I would like also to use Dotfuscator community 3.0 with WebDeployment - if you have an article on the subject it would be great ! I have tried by when method are renamed to aa, bb, cc. the application don't found anymore the methods of my project... :( Regards,
La Richesse & la Gloire ne griseront jamais que les temples
I agree with Scott here. I can't think of any good reason to use NGEN on a web app. All NGEN does is pre-JIT the IL to native assembly. This has lots of implications as it means the CLR can no longer run optimisations as it jits. The CLR is very effcient, it can often optimise things as it goes along because it knows the context it is running in. By using NGEN you remove that optimisation. The normal performance benifit associated with NGEN is improved cold start up times as the CLR doesn't have to jit compile methods before it can run them. Once the app is started though, the CLR caches jit compiled stuff so it doesn't have to do it again. By the very nature of a web app, cold start up time is irrelevant, it is just continuously running, so only the very first user will experience any slow down related to jitting, after that, the assembly is cached and no more jit compilation is required.
Simon
-
I agree with Scott here. I can't think of any good reason to use NGEN on a web app. All NGEN does is pre-JIT the IL to native assembly. This has lots of implications as it means the CLR can no longer run optimisations as it jits. The CLR is very effcient, it can often optimise things as it goes along because it knows the context it is running in. By using NGEN you remove that optimisation. The normal performance benifit associated with NGEN is improved cold start up times as the CLR doesn't have to jit compile methods before it can run them. Once the app is started though, the CLR caches jit compiled stuff so it doesn't have to do it again. By the very nature of a web app, cold start up time is irrelevant, it is just continuously running, so only the very first user will experience any slow down related to jitting, after that, the assembly is cached and no more jit compilation is required.
Simon
I agree with you for optimization - but optimization is not my main goal. My main goal is to protect the embeded code of my page and the framework that I put on the client server. My application is installed on all over the world on server that are the property of clients. So, I would like to use NGEN to put my code less (easier) readable. Fo that I have a plan. Each point is pretty simple to complete but the whole thing is more difficult because each feature is not predict to use other. Here is my steps to protect the .NET code (as strong as possible) - sign the assembly - All code of pages are in not single class but in a global DLL. This is realize with WebDeploymentProject - Compile in native code (NGEN). Put the code less readeable for decompilation. - Obfusacte the code with Dotfuscator Community 3.0 I realize each step without any problem but I cannot figure out how to implement everything together. ps: I have a click one install to install the web application. I hope this is more clear for you and I'm open to any other suggestion to protect the code efficiently.
La Richesse & la Gloire ne griseront jamais que les temples
-
I agree with you for optimization - but optimization is not my main goal. My main goal is to protect the embeded code of my page and the framework that I put on the client server. My application is installed on all over the world on server that are the property of clients. So, I would like to use NGEN to put my code less (easier) readable. Fo that I have a plan. Each point is pretty simple to complete but the whole thing is more difficult because each feature is not predict to use other. Here is my steps to protect the .NET code (as strong as possible) - sign the assembly - All code of pages are in not single class but in a global DLL. This is realize with WebDeploymentProject - Compile in native code (NGEN). Put the code less readeable for decompilation. - Obfusacte the code with Dotfuscator Community 3.0 I realize each step without any problem but I cannot figure out how to implement everything together. ps: I have a click one install to install the web application. I hope this is more clear for you and I'm open to any other suggestion to protect the code efficiently.
La Richesse & la Gloire ne griseront jamais que les temples
NGEN is meant to improve startup-time, it's not meant to protect your code. AFAIK there's no way to use an NGEN image on its own, you must also ship the original .NET assembly.
-
I agree with you for optimization - but optimization is not my main goal. My main goal is to protect the embeded code of my page and the framework that I put on the client server. My application is installed on all over the world on server that are the property of clients. So, I would like to use NGEN to put my code less (easier) readable. Fo that I have a plan. Each point is pretty simple to complete but the whole thing is more difficult because each feature is not predict to use other. Here is my steps to protect the .NET code (as strong as possible) - sign the assembly - All code of pages are in not single class but in a global DLL. This is realize with WebDeploymentProject - Compile in native code (NGEN). Put the code less readeable for decompilation. - Obfusacte the code with Dotfuscator Community 3.0 I realize each step without any problem but I cannot figure out how to implement everything together. ps: I have a click one install to install the web application. I hope this is more clear for you and I'm open to any other suggestion to protect the code efficiently.
La Richesse & la Gloire ne griseront jamais que les temples
Ahh, I see. Interesting Idea, but unfortunately that won't work. NGEN takes your IL assembly and compiles it to processor specific machine code, and places this machine code in a native image cache on the PC that NGEN was run on. You can't then copy this machine code onto another PC. You also can't delete the original IL assembly as that will also delete the machine code from the native image cache. What happens when you run your app then is the CLR first checks the native image cache to see if it's already been compiles, if it finds stuff in the cache it uses that. running NGEN on an assembly gives you no extra protection from disassembly. It can still be disassembled and reflected on. All the meta data included with a normal assembly is still present. If you are concerned with clients seeing your code your only real option is an obfuscater. (Signing the assembly does not prevent it being viewed, it only means other people can identify it as your work. Other people can even still change it, but if they change 1 assembly, they have to recompile them all as signing with a strong name ensures other assemblies will only call the original one they were referenced to.) Ultimately, C# (even with an obfuscater) is not 100% foolproof at hiding code. If you have critical proprietary algorithms that must be hidden, most people would recommend implementing the critical bits in unmanaged code.
Simon