I'm copying my program to a Virtual Machine to see what software I need and which settings I need to have enabled (or disabled). My program is running fine on my work laptop and on my own laptop (older version), but on the VM the program throws an error during run time.
My program is made out of one executable and many DLLs, both the Executable and the DLLs are able to start just fine including using the dependency system.drawing.common. But one of the classes in one of the DLLs gives an error that the dependency system.drawing.common could not be loaded. Rebuilding the DLL in question doesn't give a warning that something is wrong. See image below for the error I see.
[ERROR][12/18/2019 11:04:02 AM][Thread 0006]>
[akka://ModulairVisionFramework/user/AcquireImageActor] Could not load file ?
or assembly 'System.Drawing.Common, Version=4.0.2.0, Culture=neutral, >PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
Cause: System.IO.FileNotFoundException: Could not load file or assembly >'System.Drawing.Common, Version=4.0.2.0, Culture=neutral, >PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
File name: 'System.Drawing.Common, Version=4.0.2.0, Culture=neutral, >PublicKeyToken=cc7b13ffcd2ddd51'
at CameraSystem.Actors.AcquireImageActor.<.ctor>b__2_0(AcquireImage resp)
at lambda_method(Closure , Object , Action1 )
at Akka.Tools.MatchHandler.PartialHandlerArgumentsCapture2.Handle(T >value)
at Akka.Actor.ReceiveActor.ExecutePartialMessageHandler(Object message, >PartialAction`1 partialAction)
at Akka.Actor.ReceiveActor.OnReceive(Object message)
at Akka.Actor.UntypedActor.Receive(Object message)
at Akka.Actor.ActorBase.AroundReceive(Receive receive, Object message)
at Akka.Actor.ActorCell.ReceiveMessage(Object message)
at Akka.Actor.ActorCell.Invoke(Envelope envelope)
What can the cause be that the main executable and the interface of the DLL are both using system.drawing.common fine, but a class in the DLL in question cannot use the dependency? And how can this issue be resolved? I have not faced this issue on my work laptop so far or on another computer (older version of my application but still uses system.drawing.common).
EDIT
In both the executable project as in the DLL in question I'm using the NuGet package manager for system.drawing.common. How the package is included:
<PackageReference Include="system.drawing.common" Version="4.6.0" />
I hit this same problem a week or so ago. If this is a .NET core assembly, the way you reference it makes a big difference. Instead of referencing the .NET lib directly (right click -> add reference), use a package reference in the project file:
<PackageReference Include="System.Drawing.Common" Version="4.6.0" />
Related
I've created a Class Library in C# .Net Framework 4.8, and in the solution I've also included a Console Application, same target.
I'm running both in a x64 configuration.
No errors on build.
I referenced the App in the Library, and when I run a Button in a Form in the Class Library I'm getting an error:
System.IO.FileNotFoundException: Could not load file or assembly
'ExampleApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or
one of its dependencies. The system cannot find the file specified.
File name: 'ExampleApp, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null'
I've combed the internet and SO for a solution. I tried repairing Visual Studio, I tried deleting the .vs folder in the projects, I tried things like:
solution 1
and
solution 2
I seriously tried everything I could think of. It has to be something to do with the .dll dependencies imho, because the only one that my ExampleApp is using is the Microsoft.CognitiveServices.Speech reference which I installed via NugetPackage in my solution.
No idea how to debug this further or get a proper trace stack from this error...
Any ideas on how to proceed?
Thanks
Solved by changing the .dll's Copy Local property to True
Exactly #Yafim Simanovsky, I solved also my problem by changed <Private> flag to True.
My problem (“Could not load file or assembly…”) was with new Designer ‘WpfSurface.exe’ from VS 2022, which after changing the reference tags ‘Private’ to True, was able to copied all dependent .dll files to Cache.
I have an c# application using 'Microsoft.SqlServer.Replication .NET Programming Interface DLL.
(Microsoft.SqlServer.Rmo.dll)
I need there the TransSubscription and TransPublication.
I can build the solution without any error or warning, and run it in Debug and Release mode on my computer. But if I would like to start the release application an another computer, i receive the error:
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.SqlServer.Replication, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.SqlServer.Replication, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'
I tried it to have as x64 and x86 application, no affect. I cannot interop the DLL, there will be errors in Vistual studio.
Anyone has an idea?
Thank you
Edit:
Meanwhile i did some more testing..
I have installed on a new VM SQL server to get only the available, and in the rght version dll. Installed VS and build the project. This was sucessful, no errors. But if i am starting the app, already in debug mode it crashed with the same error code. any idea?
The dll is referenced all build is completed.
Edit:
According: https://learn.microsoft.com/en-us/sql/relational-databases/replication/concepts/replication-management-objects-concepts?view=sql-server-ver15 i need to add Replication Agent Library (REPLAGNT.dll) but this i cannot do in VS, "A reference to .... could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component". What do i do wrong?
For me it sounds like you referenced a dll which is located in a local folder, which works okay as long as you are working on your machine, but crashes as soon as you using another machine. After a build/rebuild a dll should be located in the bin folder.
I just changed the .csproj from <TargetFramework>netcoreapp3.1</TargetFramework> to <TargetFramework>netstandard2.0</TargetFramework> and when debugging, I receive the following:
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly '..., Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null' or one of its dependencies.
The system cannot find the file specified. at CDMToJSON.Program.Main(String[] args)
I tried adding all missing .dll's in the folder (Sources\CDMToJSON\bin\Debug\netstandard2.0), but for one with the Newtonsoft.Json the error kept persisting, which made me think that there would be a better way to add these NuGets and dependencies.
Therefore, how can I add all these .dll's properly after changing the Targeting Framework?
netstandard TFMs are only for libraries. They cannot be used for projects which are directly executable, such as desktop apps, console apps, or unit test projects.
You need to pick a concrete runtime that your program will target, such as netcoreapp3.1 or net5.0, and then target it.
I am creating a c# .net framework library (.dll) that will act as a plugin for another piece of software. I want to use the Newtonsoft.json library but when the I call the json library I get the classic "FileNotFoundException":
Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
The .dll is definitely being copied to the directory I am trying to run the plugin from. A lot of others have had this issue and I have tried everything I've seen (updating, reinstalling, etc.) but no luck yet. Because this is a class library I do not have an "app.config" file to play with binding redirects, so I haven't been able to try that.
I have very basic code right now, this package is the only external reference I am using. I've only been working on this today, only ever trying with Newtonsoft.Json version 12.0.2. It is weird to me that it appears VS is looking for 12.0.0.0, however. This is not an option to download. Similarly, I've tried downgrading to version 11.0.2, and then it gives me the same error saying it can't find version 11.0.0.0.
Even though your project may not have an .app config, you can still view the package references by unloading your project and viewing the .csproj file.
To try and force a direct reference to Newtonsoft.Json 12.0.2, you can add this snippet
<ItemGroup>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.2</Version>
</PackageReference>
</ItemGroup>
I would recommend removing any other references in your .csproj for Newtonsoft.Json as well
I have a .NET Core project with many libraries as dependencies.
I wanted to change code in one of the library (a dll dependency) and wanted to run the project using the said new dll.
I changed the file version of the dll in the deps.json file but when i run the project using dotnet project.dll I see this exception thrown:
Application startup exception: System.IO.FileNotFoundException: Could not load file or assembly 'CuPletEngine, Version=16.0.229.1809, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
I made the change to deps.json file in order to force the application to to look for a different dll version.
Why would it still look for older version?
Please help.