问题
We are trying to come up with a good solution for sharing common libraries, files, executables. We have use case like below
Service1 and Service2 are two WCF services developed and maintained by two separate teams and they follow their own release schedules. Common.dll is provided by separate team and they release as per their own schedule.
When Common.dll is released beside each Service team testing it, Common team has additional responsibility to approach every service team and their by make sure those changes are dropped into multiple BIN folders and there will be a scenario where we might miss in one of the BIN folder.
Service1
Folder: C:\Services\Service1\Bin
Common.dll
Common.dll.config
Service1.dll
Service2
Folder: C:\Services\Service2\Bin
Common.dll
Common.dll.config
Service2.dll
Instead of having Common.dll and Common.dll.config into two separate Bin folders what is the best way for Service1 and Service2 refer them.
This is not like below. I do not want to have Common.dll and Common.dll.config in C:\Services\Service1\Bin and also C:\Services\Service2\Bin
How do I keep common code shared between projects in c#?
Working with Common/Utility Libraries
Just started research is it possible ?
UPDATE
I researched many ways but if I do not have dlls in my BIN folder of my service, I am unable to start my service. So it seems I need to have all my dlls in my BIN folder. So I wrote a method which runs in OnStart event of my windows service which is hosting my WCF service to copy files from common location to my BIN folder.
Instead of blindly copying the DLL, I am trying to compare DLL from common folder to my BIN folder DLL and if not same then copy from Common folder and replace in BIN folder. Any suggestions how to compare two dlls in C# code?
protected override void OnStart(string[] args)
{
try
{
LoadAssemblies();
restServiceHost = new ServiceHost(typeof(restService.NonVaseImage));
restServiceHost.Open();
}
catch (Exception ex)
{
\\handle exception
}
}
来源:https://stackoverflow.com/questions/59849441/c-sharp-common-libraries-same-location-for-different-wcf-services