I need to create ASP.NET CORE 2.1 web API from one class that is in Class library project(Targets 4.7.2).
I have added references to Microsoft.AspNetCore and Microsoft.AspNetCore.Mvc.Core.
Following call throws exception:
CreateWebHostBuilder().Build().Run();
Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Output window:
Exception thrown: 'System.IO.FileNotFoundException' in Microsoft.Extensions.DependencyInjection.dll
An exception of type 'System.IO.FileNotFoundException' occurred in Microsoft.Extensions.DependencyInjection.dll but was not handled in user code
Could not load file or assembly 'System.Runtime.InteropServices.RuntimeInformation, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
I have tried adding System.Runtime.InteropServices.RuntimeInformation reference manualy with no success.
Am I missing something here?
If you have added the reference as nuget pakage you can try to add this property group in the csproj:
<PropertyGroup>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> </PropertyGroup>
This property will copy the nuget dll in the output directory instead of use the dll in the nuget memory cache.
This can help you if in your solution you have many projects that refers different version of the same package (related dependencies too).
If you have added the reference as a simple "reference" to a known dll, you should verify the dll is in the output directory. Verify the version of that dll too. If it's different and the dll reference refers a strict version could be a problem.
Related
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 trying to use MathNet.Filtering (https://github.com/mathnet/mathnet-filtering) and I receive during runtime the error Could not load the file or assembly 'MathNet.Filtering, Version=0.7.0.0, Culture=neutral, PublicKeyToken=null or one of its dependencies . The system cannot find the file specified. This happens when trying to use any part of the MathNet.Filtering class.
Such as
MathNet.Fitering.OnlineFilter myFilt = MathNet.Filtering.OnlineFilter.CreateBandpass(MathNet.Filtering.ImpulseResponse.Finite, 8000,100,15000,50);
I am already referencing MathNet.Numerics as it is a dependency to MathNet.Filtering.
I am compiling and running with .NET 4.6.1 and the dll for MathNet is built to target .NET 4.6.1.
Using dotPeek I can see there are other dependencies:
MathNet.Numerics (already referenced version 4.9.1.0)
mscorlib
System
System.Core
System.Numerics
System.ValueTuple
[]
I am struggling to see why I am getting Could not load the file or assembly . There are no external references missing.
Is the problem related to System.ValueTuple?
I can use the MathNet.Numerics classes without any issue, this has all the same dependencies except System.ValueTuple
But when I try and explicitly reference System.ValueTuple's DLL I receive
System.ValueTuple exists in both [path to reference] and C:\Windows\[...]\mscorlib.dll
Any ideas what is going on here? Stuck at this for hours
Thanks
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.
I'm getting the following exception when trying to use the Google Auth API:
System.IO.FileNotFoundException : Could not load file or assembly 'System.Net.Http.Primitives, Version=4.2.28.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
----> System.IO.FileNotFoundException : Could not load file or assembly 'System.Net.Http.Primitives, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
The exception happens in Google.Api.Core.dll.
If I check the /Bin folder I can see Sytem.Net.Http.Primitives.dll in there and the version is 4.2.28.0.
I have tried updating the Microsoft HTTP Client Libraries NuGet package but that didn't help.
Is the problem something to do with a mismatch of .dll versions? If so how can I resolve that? Or is it something else entirely?
Double check if the assembly file is there in the bin folder and if its there, then try removing the reference and again add it to your project.
The version should be the same as expected. Also check on your web.config too for what it has about this particular assembly.
In your error code, I can see two different versions for the same file. Means probably, you are getting a clash between the existing assembly and the referenced assembly. Check you web.config for which version is referenced there and make sure you have the same version added to your project.
This link might help :
Could not find assembly System.Net.Http.Primitives
I recently added the package LinqToExcel to my .net 4 WPF project and now when entering the designer I am presented with the following error:
System.IO.FileNotFoundException
Could not load file or assembly 'Castle.DynamicProxy2, Version=2.1.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' or one of its dependencies. The system cannot find the file specified.
LinqToExcel only has one dependency - log4net, which it installed as part of the NuGet process. Both are referenced and set to Copy Local. I'm not sure where the reference to Castle is coming from or how to go about fixing it.
Does anyone have any suggestions?