I have a .NET service project that requires one dependency (let's call it A.dll). The A.dll requires B.dll and if I don't have B.dll in my project Visual Studio complains and fails to build. But I do not use anything that is inside B.dll in my program. Is it okay if I compile my project with both A.dll and B.dll but only ships my project with A.dll?
From my tests the service runs fine with just A.dll (after all, I am not using anything from B.dll) but I am wondering if there is an issue in doing so that I am not seeing.
Update: My objective with that is to reduce overall application size that is shipped to clients.
It'll probably be fine, but I wouldn't recommend it as good practice.
If you're just trying to cut down on file count then try compiling both DLL's in to the resultant EXE using ILMerge.
You can add it as a Post Build Event with something like this command:
"C:\Program Files (x86)\Microsoft\ILMerge\ILMerge.exe" /target:winexe /out:temp.exe $(TargetName).exe A.dll B.dll
rename temp.exe $(TargetName).exe
The other option you've got is decompiling A and removing the dependency of B by removing all the methods that you're not using that need B.
To do that you can use ILSpy.