Lack of dependent assemblies - how to get a compiler error, not a runtime error

Situation

The assembly Adam.dll has a link to the assembly Frank.dll. Adam.dll is placed in the shared assemblies folder and then links to my application as a binary link.

If I run the application, it will crash (and this is correct) because the Frank.dll file is missing.

If, however, I put Frank.dll in the shared assemblies folder, the .net compiler is smart enough to move it to the bin folder and my application will work, although I do not have a direct link in my application to Frank.dll

What I want

. the .net compiler is obviously smart enough to implement my Frank.dll application. Is it possible to set the compiler parameter so that this flag is marked as an error during compilation?

Thanks,

+1
source share
1 answer

I'm not sure which “general assemblies” folder you are talking about, but I would not be too sure that Visual Studio really “understands that your application requires Frank.dll” - I suspect that it is more likely that it copies everything assemblies assembled there. What happens if you place an unrelated fee there? If you could find out in more detail what exactly is happening, what type of project you are creating, and how you add a link to Adam.dll, this will help.

I don’t know how to force dependent assemblies to be copied in all situations, because in reality this may not be necessary. Frank.dll may be needed only if you use certain functions of Adam.dll, for example.

If some type in Adam that you used opened the type from Frank in its public API, then the compiler will give you an error - but, obviously, you do not want to add bits to the open API only for kicks.

Although I know that this is not the answer you are looking for, I think you just need to grin and carry it ... your code has enough complex dependencies, what is the real problem? Most likely, you will spend enough time due to missing dependencies, which is worth trying to develop a “fix” scheme? You could write a program that downloaded your application assembly, found all its dependencies, and then checked that they were all present - and recursively. He will probably ignore dependencies already in the GAC. I'm just not sure it is worth it.

0
source

All Articles