R
R
Ruslan2021-11-08 15:48:56
C++ / C#
Ruslan, 2021-11-08 15:48:56

How to use different versions of nuget packages in one project?

Hello.
imagine the following situation.
There is my project (.net framework 4.7.1)
in which I added nuget-package A and B
nuget-package A depends on nuget-package C v. 1.0.0,
nuget package B depends on nuget package C v.1.1.1.
at startup I get the error "System.IO.FileLoadException: Failed to load file or assembly C, Version=1.0.0.0
" nuget-packages used its own version.

Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya Golets, 2021-11-18
@igolets

Hello. In a good way, it's better to make two projects, run them in parallel and somehow (via the fancy MessageBus, or some RESTful request) pull the second process out of the first one.
But if you really want to vlob, then I can only advise you to dig this thing: https://docs.microsoft.com/ru-ru/dotnet/api/system...
It will also be important to take into account that here the downloaded assembly is loaded into the domain applications. If the same assembly of a different version is already loaded in this domain, there may be overlays. Therefore, it would be nice to study the topic of domains, here, for example https://docs.microsoft.com/ru-ru/dotnet/framework/...
I didn’t dig the topic myself, I studied it only in preparation for the exam, but as I understand it, the essence will be almost the same as the first option - in fact, the second thread is launched from the main code in another domain. The only difference is that you can try to make one application that contains the second one and can run it.

E
Evgeny Glebov, 2021-11-18
@GLeBaTi

Create your own DLL which will use package B . Then there will be no collisions.
Those. App.exe uses package A and MyLib.dll
while MyLib.dll uses package B

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question