0
votes

I created a c# Library class (called IfcManagerLib) in Visual Studio and installed some packages (only on the library) via the NuGet Packages Manager. Now I want to use this library through a Console App (called IfcManagerConsole), so I created one in the same solution, added a reference to IfcManagerLib and added "using IfcManagerLib;" on the top of the console class. However, if I start the console it always breaks at the moment it tries to execute something from the library class. It outputs the following error:

System.IO.FileNotFoundException HResult=0x80070002 Message=Die Datei oder Assembly "Microsoft.Extensions.Logging.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden. Source=IfcFileManagerLib
StackTrace: at IfcFileManagerLib.IfcManager.Start() in C:\Users\David\Dropbox\Visual Studio\source\repos\IfcFileManager\IfcFileManagerLib\IfcManager.cs:line 101 at IfcFileManagerConsole.Program.Main(String[] args) in C:\Users\David\source\repos\IfcFileManager\IfcFileManagerConsole\Program.cs:line 36

Inner Exception 1: FileNotFoundException: Die Datei oder Assembly "Microsoft.Extensions.Logging.Abstractions, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.

(Sorry, some of it is in German, but I think you mostly know what it is supposed to say)

What really bothers me, is that the path to the IfcManagerLib (C:\Users\David\Dropbox\Visual Studio\source\repos\IfcFileManager\IfcFileManagerLib\IfcManager.cs) in the above error message is not correct. It is an old path. I rebuilt the solution, unistalled and reinstalled all packages, but the error still exists. Also: "Microsoft.Extensions.Logging.Abstractions, Version=2.1.1.0" is not correct, I updated it to 2.2.0.0.

Am I correct in the asumption that the console project does NOT need to have the packages installed that the library uses? If yes, what did I do wrong?

EDIT: Okay. Cleaning and rebuilding the solution did a lot already. However, there is one dll called Xbim Geometry that the Console still cannot find. Here is the error message:

System.IO.FileLoadException HResult=0x80131621 Message=Failed to load Xbim.Geometry.Engine64.dll Source=Xbim.Geometry.Engine.Interop StackTrace: at Xbim.Geometry.Engine.Interop.XbimGeometryEngine..ctor(ILogger`1 logger) in C:\buildagent_os_work\1\s\Xbim.Geometry.Engine.Interop\XbimGeometryEngine.cs:line 65 at Xbim.ModelGeometry.Scene.Xbim3DModelContext.get_Engine() in C:\buildagent_os_work\1\s\Xbim.ModelGeometry.Scene\Xbim3DModelContext.cs:line 486 at Xbim.ModelGeometry.Scene.Xbim3DModelContext.CreateContext(ReportProgressDelegate progDelegate, Boolean adjustWcs) in C:\buildagent_os_work\1\s\Xbim.ModelGeometry.Scene\Xbim3DModelContext.cs:line 678 at IfcFileManagerLib.IfcManager.Start() in C:\Users\david\source\repos\IfcFileManager\IfcFileManagerLib\IfcManager.cs:line 82 at IfcFileManagerConsole.Program.Main(String[] args) in C:\Users\david\source\repos\IfcFileManager\IfcFileManagerConsole\Program.cs:line 36

Inner Exception 1: FileNotFoundException: Die Datei oder Assembly "Xbim.Geometry.Engine.dll" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.

What I find odd is that unlike the other dlls that I installed on the library project through NuGet manager, the XbimGeometry dll is located in two folders named x64 and x86 where there is a 64-bit and a 32-bit version. Could that be the problem?

1
Are both the class library and the console app in the same solution? If yes, did you add the reference as project reference?Klaus Gütter
@KlausGütter Yes, they are in the same solution and yes, I added it as a project reference.Truning
In the properties of the reference, "Copy Local" should be set to true. Can you please check?Klaus Gütter
I personaly don't like to build a project in dropbox or in different folders from the solution. Its probably not the problem you are having though I would recommend to change that. If nothing recommended here works you can always compile your first project and reference a DLL from that. That should do the trick... Try the clean/ rebuild + copy local first anyway...Kim Lage
@KimLage Yes! This fixed it, thank you! I thought it wouldn't be a good idea to have my solution on dropbox, which is why I wanted to move it. However there is still one specific dll that the console cannot find, but is in the folder of the library. It is a package called Xbim Geometry that I installed through the NuGet Manager. What I find odd is that unlike the other dlls the XbimGeometry package creates two folders (x64 and x86). Can that be the problem? I will add the error message to the main question.Truning

1 Answers

0
votes
  1. Can you do a clean solution and rebuild the solution.
  2. Can you set the reference as Project reference and set "Copy Local" for that reference?