C
C#3y ago
_moare

Use dll from project reference

I have a class library which adds a few helper functions to a nuget package. This nuget package requires the System.Windows.Forms.dll. My main project references the class library and my class library references the nuget package. When i add the DLL to the main project and reference it from there everything works as expected. But when i add it to my class library, it cant be found when running. Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Das System kann die angegebene Datei nicht finden. Is there a way to make this work? Project: .net core 6
4 Replies
Anton
Anton3y ago
the windows forms reference is not transitive aka private. it has to be loaded at the moment that you're trying to use it so you need to add a dependency on it in the class library
_moare
_moareOP3y ago
i would like to have it only on the class library, but i have to add it to the startup project to make it work
Anton
Anton3y ago
yeah, add it to the class library. does that not work?
_moare
_moareOP3y ago
no that does not. I does copy to the output dictionary, but when i run the startup project and i ties to access it, i get the error states above. it does however work when i add it to the main project
Want results from more Discord servers?
Add your server