DLL Unable to load file or assembly [Answered]
Hi, i've made my own DLL and when i try to create a new variable with a class from this DLL, it launch the following error :
'System.IO.FileNotFoundException' an error occurred in System.Windows.Forms.dll
Unable to load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
and if i remove the new variable this error disappear and my program goes running, have you any idea why this following error occur ?16 Replies
to add more details, i use the following package in the DLL maybe i forgot to include this package while generating my dll but i'm not sure
here an example of my code :
If i comment the line with test the program work ...
Try adding reference System.Runtime to the project or nuget: https://www.nuget.org/packages/System.Runtime/
it didn't work :/
What kind of app is running your library/DLL and what runtime does it use?
It is just some class which use io port to make method for communicate with an electronic card and it use the last version of runtime I guess
Don't guess. The error is potentially about a version mismatch because it should ship with one of the apps.
Are the main program and this library in the same VS solution using project references? Or are you trying some other way to create this?
Nop they aren't I've created them yesterday so that why I said it should be the last version for both
I've created a the library yesterday and the winforms today and I e implemented the library to the winforms
Are they in two separate solutions? If so, do they have reason to be?
Yes they are, there is no particular reason just in the first solution there is my library and other project and i've created a win form only to test de library
So keeping them in separate solutions makes things harder because you need to either: 1. manually transfer the DLL and all required components to the main project build or 2. publish as a NuGet package and setup a local NuGet server.
Ok so I will put them in the same solution it will be easier then
Whereas if you have them in the same solution...you right click the main project in VS: Add -> Project Reference. Then click your library.
The build system will then know exactly what other dependencies might be required (without going the NuGet package route).
Thanks it work now 😁
I will take note of this
✅ This post has been marked as answered!