简体   繁体   中英

How to make a c#.net application portable

Im searching for a way to make my c#.net Application portable (or at least no installation needed). Some Background: I'm developing a small File-Manager for our Customers. As not every Employee of our Customer got Admin rights I need to hold it as easy as possible to use it.

My idea was to just deliver an .exe or Zip(containing .exe + dll of .net), that all Employees can use it by double clicking.

Is there any way to "bind" the dll to the exe?

You can combine multiple .NET assemblies together using ILMerge: http://research.microsoft.com/en-us/people/mbarnett/ilmerge.aspx

It's somewhat equivalent in concept to a static linker from C/C++ (except pretend that .lib files are directly executable).

Why not just use ClickOnce deployment?

http://msdn.microsoft.com/en-GB/library/142dbbz4%28v=vs.90%29.aspx

No admin rights required... auto updating... what's not to like?

(Just deploying executables is a great way to eliminate your ability to update your clients... why do that?)

Try ILMerge ,

ILMerge is a utility for merging multiple .NET assemblies into a single .NET assembly

http://www.microsoft.com/en-in/download/details.aspx?id=17630

I also use this command line tool to merge several dlls and exe into single exe, use is very simple:

ilmerge /target:winexe /out:destination.exe source.exe dll_1.dll dll_2.dll dll_3.dll

In basic the program written in .net is 'portable' - you do not need to install it. (but the compatible .NET framework must be installed on client machine)

If you like to provide single assembly, you need to download and install the IlMerge utitlity (see Dai's answer) and then have either post-build command defined or I usually do a bat file with content like this:

"c:\\Program Files (x86)\\Microsoft\\ILMerge\\ILMerge.exe" /target:winexe /targetplatform:"v4,C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework.NETFramework\\v4.0" /out:ALLINONE.exe PROGRAM.exe LIBRARY1.dll LIBRARY2.dll

Note, the paths depends on how it is on your system...

Also I recommend to ' obfuscate ' your assembly - you can use for example good opensource utility ' ConfuserEx '

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM