Advertisement

Where to put dependencies?

Started by May 10, 2017 08:42 PM
6 comments, last by jpetrie 7 years, 6 months ago

Hi, I'm writing a program in C#, and I realize that there are .NET runtime files and potentially other DLL files or the like, which my program may use.

So I got one of those programs that can tell me what all the dependencies are (all the files that my program is using). I haven't tried it yet, but it doesn't seem like it should be hard to use.

But my question is if I want to distribute my program, where should I put these files? Should I just include them in the same folder with the EXE, or is there somewhere that I need to reference them to specify where they are?

You should first review the legal entanglements that come with each dependency; in some cases you are not permitted to directly distribute the DLLs or otherwise, but must ship a redistributable installer.

If you aren't so encumbered, you can usually just .zip everything together in the simplest case, so that when an end-user unzips the archive they get a folder with your .exe + all dependencies they can run.

If you do have distribution requirements, you may need to build an installer. This is likely the better option, but it involves more work.

Advertisement

The way it must be for me is that when I put the files on the removable storage device, they MUST be in the final position as they will be used, so I can't zip anything or make an installer or anything like that. I'm just wondering how I should position all the files - do they need to be in a specific directory relative to the EXE?

And no, legal issues won't be a problem in this case.

If they are DLLs, putting them next to the .exe is the safest option. Literally in the same folder as. DLLs are searched for in a specific order.

That's good to know, thanks. But what about other dependencies, like COM, ActiveX, OLE, etc. or whatever .NET may have of its own variety? Do they all work the same way as DLLs?

In other words, if I just take every file that the dependency checking program tells me I need, and copy them all right into the same folder with the EXE, will that guarantee that there won't be anything missing or unable to be located?

But what about other dependencies, like COM, ActiveX, OLE, etc. or whatever .NET may have of its own variety? Do they all work the same way as DLLs?

Parts of them might, but most of them are more than simple DLLs. You also can't distribute most of those directly, legally. They require redistributables, or that you're using a new enough version of Windows such that the dependency is part of Windows.

In other words, if I just take every file that the dependency checking program tells me I need, and copy them all right into the same folder with the EXE, will that guarantee that there won't be anything missing or unable to be located?

Nope. Tools like that (depends.exe and such) only look for a specific kind of dependency (basically, DLLs and PE references). A program can contain other dependencies, and it's dependencies can further contain such dependencies, that aren't DLLs. For example, some library may assume the presence of a particular tool known to be available if certain versions of .NET are available (msbuild.exe). depends.exe won't capsure that.

Advertisement

So I should include the .NET runtime installer as well? (I'm using C#, btw)

Yes, you should.

This topic is closed to new replies.

Advertisement