Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
441 views
in Technique[技术] by (71.8m points)

visual studio 2017 - Different Core or nuget package DLLs inconsistently published or not published

The software that I am developing uses a system of loadable plugins discovered at run-time and loaded through Reflection. Each of the plugins has its own set of DLLs that mostly originate from various Nuget packages. When I publish a self-contained deployment for a particular platform, some of the plugins load successfully but others throw exceptions similar to below:

Could not load file or assembly 'System.Data.SqlClient, Version=4.6.1.2, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

or

Could not load file or assembly 'MailKit, Version=2.10.0.0, Culture=neutral, PublicKeyToken=4e064fe7c44a8f1b'. The system cannot find the file specified.

etc. The DLLs with the names mentioned above (ex: System.Data.SqlClient.dll, MailKit.dll) do exist in the publish subfolder of the solution, yet they are still reported as missing by the Activator.CreateInstance() call, whereas the rest of a few dozen DLLs load fine. As long as I do not publish, the project runs fine and unit tests are able to pass through the code that uses these DLLs. When I check properties of the faulty packages, they seem to be different versions from what is reported above. Example, for Nuget package System.Data.SqlClient 4.8.2 I see:

enter image description here

This does not match 4.6.1.2 reported by the exception.

What is causing this mess, and what has to be done in VS, .csproj, or dotnet publish command, to have ALL DLLs consistently and correctly published?

Any mention of different versions of Visual Studio or .NET Core is offtopic. I am locked in these and have to work with what I am told to.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...