0

i have developed a C# .Net (Crystal Reports) Application.

Is there any way to generate as output : the .Net executable and its needed (references/dependencies) that i will be able to run this executable in another computer withou any errors or extra installation ?

example (in a folder, i find the exe, and the DLLs) without importing the DLLs manually (Not useful with crystal Reports)

without merging any files !!

Omar_0x80
  • 783
  • 1
  • 9
  • 16
  • Answered here: http://stackoverflow.com/questions/10137937/merge-dll-into-exe – Nathan Cooper Jul 19 '14 at 12:17
  • 1
    If that's not the answer then you need to clarify your question. – John Koerner Jul 19 '14 at 12:19
  • i don't need to merge any dll, i just need to generate the dlls – Omar_0x80 Jul 19 '14 at 12:19
  • 1
    "without merging any files !!" isn't clarification. If you are after an exe that includes its reference look at the link, if you're not I have no idea what your after. When you build it will put the dlls in bin with the exe, and that's as far as you can get without merging. – Nathan Cooper Jul 19 '14 at 12:22
  • .Net exe is just an assembly ! sometimes ILMerge fail to merge DLLs if they are not .Net Assembly – Omar_0x80 Jul 19 '14 at 12:24
  • I seem to recall a situation at work with the use of CrystalReports. I can't remember what it was off the top of my head, but is this the library in question that is giving you a fit? The number one answer to if it will work or not is to try it, and analyze any errors – Robert Snyder Jul 19 '14 at 12:37

2 Answers2

2

You have to set the "copy local" property of your references to "true". This way they will be copied in the compilation folder.

If you want only one executable without any dlls, you can have a look a ILmerge, but this can be a little harder to achieve.

codea
  • 1,439
  • 1
  • 17
  • 31
  • and after copying all the references locally, the executable will not need any other references if i copy it with its local DLLs to another machine? i mean, i will not have to install crystal remports / Visual Studio etc .. in the other machine ? – Omar_0x80 Jul 19 '14 at 12:34
  • 1
    @user3501635 it is sufficient to copy the debug/release folder over to said other computer. There may be a few extra not-needed files (such as the symbols files, and the vhost files) but it should run. Remember to just keep all those together – Robert Snyder Jul 19 '14 at 12:36
1

I find that visual studio generally does a good job about adding the required referenced libraries in its bin output. That said there are still occasions where it misses one. If that is the case get your properites tab open and pinned. Then open your solution tab and expand the references. Click on your reference and change its property of "Copy Local" from False to True.

if you added the library to your solution (IE a non-managed library) then click on it and look at its propertys and change its Build Action to Content

Robert Snyder
  • 2,399
  • 4
  • 33
  • 65
  • and after getting all the dlls in the same folder with the executable, the application should work in another Os missing the Global Assembly Cache (GAC) Dlls ? or still miss files other than the referenced libraries ? – Omar_0x80 Jul 19 '14 at 12:30
  • 1
    well if the other computer is missing a dll that is supposed to be in GAC that is a different problem. However some libraries don't have to be put in GAC as long as you have them in the same folder as the executable. My solution will cover a large portion of any run-time errors that involve missing assemblies. – Robert Snyder Jul 19 '14 at 12:33
  • "a different problem" then, how to be sure the my application will work in any client's computer ? and thank you – Omar_0x80 Jul 20 '14 at 01:55
  • only sure fire way is to just try it – Robert Snyder Jul 20 '14 at 02:35