I created a .net standard 1.3 PCL and referred newtonsoft.json package in that library using visual studio 2015.
After that i tried referring this dll to a console application of .net framework 4.5.2 , in the console application on execution, i get an error as
Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
I see that in PCL on building project i am not getting the dlls of dependent package , why does that problem exist?
How to fix this?
Note -
build location for console application and PCL library is same.
best way i found on exploration is to create nuget package using dotnet pack and refer it in project
Related
I have a C# project (ProjectX) that I am trying to upgrade from using .NET Standard 2.0 framework to .NET 6.0. The upgrade seemingly goes smoothly and we package it into a nuget using GitLab. Now when I reference the updated package from another project (already upgraded to .NET 6.0) I get the following warning:
Warning CS8032 An instance of analyzer {class inheriting from Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer} cannot be created from ProjectX.dll: Could not load file or assembly 'System.Collections.Immutable, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified..
Everything I've read suggests that this is likely caused when the sdk isn't on the same version as the source generator but as far as I can tell, this not the case.
I've tried adding the Systems.Collections.Immutable package directly to ProjectX also with no luck.
I Fixed this bij downgrading 2 nugate packages in my code analyzer:
Microsoft.CodeAnalysis.CSharp to 3.8.0
icrosoft.CodeAnalysis.CSharp.Workspaces to 3.8.0
We have a solution with two projects:
A desktop App using WPF (.NET 4.6)
A class Library (.NET Standard) that connects to remote REST API.
We are using NewtonSoft JSON 13.0.0.1 (installed via NuGet) in the class library project. We referenced the class library project in the WPF project. Whenever we call a method in the library project from WPF application, we get the following error:
Could not load file or assembly 'Newtonsoft.Json, Version=13.0.0.0... could not find the file...
I am clueless as to why 13.0.0.0 is being searched when 13.0.0.1 version is installed, I even tried with the 12.x. version, it also gives the same error only searching for 12.0.0.0 version.
Is this a WPF .NET and Libary .NET Stanard conflict issue? How to resolve this?
I'm making an iOS/Android app that will work with Azure IoT Hub. The latest Microsoft.Azure.Devices version from what I understand is only compatible with .Net Standard projects. I've been trying to follow these twho tutorials (1, 2) to convert PCL project to .Net Standard project to no avail, and I'm lost on what I'm doing wrong.
These are the steps that I'm taking.
Create new Cross Platform App called TestProject. Xamarin.Forms -> Blank App -> Portable Class Library (PCL)
Right click solution -> Add New Project -> .Net Standard -> Create .Net Standard Library called TestProject.Core
Delete the auto generated class Class1.cs and move App.xaml and MainPage.xaml to TestProject.Core.
Delete Portable Library TestProject.
Rename TestProject.Core to TestProject.
Add TestProject reference to iOS and Android.
Click on TestProject and select Edit TestProject.csproj. Change PropertyGroup to following:
<PropertyGroup>
<TargetFramework>netstandard1.4</TargetFramework>
<PackageTargetFallback>$(PackageTargetFallback);portable-win+net45+wp8+win81+wpa8
</PropertyGroup>
Right click on solution and select Manage Nuget Packages For Solution.
Check Include Prerelease and install 2.3.5.256-pre6 Xamarin.Forms on TestProject, TestProject.Droid and TestProject.iOS.
Clean and Rebuild solution.
Right click on TestProject and select Manage Nuget Packages. Install Microsft.Azure.Devices
Clean and Rebuild.
Add code to TestProject that uses Microsoft.Azure.Devices.
Rebuild and get error:
Project File Line Suppression State Error Exception while loading assemblies: System.IO.FileNotFoundException:
Could not load assembly 'Microsoft.Azure.Devices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
Perhaps it doesn't exist in the Mono for Android profile? File name: 'Microsoft.Azure.Devices.dll'
From what I can understand I am missing Microsoft.Azure.Devices Nuget package on
TestProject.Droid, however, when I attempt to install it, I get the following error:
Could not install package 'System.Threading.Overlapped 4.3.0'.
You are trying to install this package into a project that targets
'MonoAndroid,Version=v7.1', but the package does not contain any assembly references or
content files that are compatible with that framework.
When I try to install *Microsoft.Azure.Devices** on iOS:
Could not install package 'System.Threading.Overlapped 4.3.0'. You are trying to install
this package into a project that targets 'Xamarin.iOS,Version=v1.0', but the package does not
contain any assembly references or content files that are compatible with that framework.
I'm making an iOS/Android app that will work with Azure IoT Hub. The latest Microsoft.Azure.Devices version from what I understand is only compatible with .Net Standard projects.
Per my understanding, you could leverage the Azure IoT Hub client SDK portable library Microsoft.Azure.Devices.Client.PCL which supports Android, iOS, Windows 10 (UWP) and Windows Phone (WinRT). Also, here is a sample uses Microsoft.Azure.Devices.Client.PCL, you could follow here.
I've ran into a weird problem.
I basically have my own web-stack for .NET-core which I've built into a few .dlls, and I want to reference these from another ASP CORE-solution.
VS seems to find the assemblies, where I can navigate types etc.
I can also build the project without any issues, but when IIS then runs the server I get an internal server error stating:
FileNotFoundException: Could not load file or assembly 'myDLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
The referenced DLLs are in the debug-folder, and the really weird thing is that if I create a new ASP Core project in the same solution as the web-stack, I can reference and use it without any problems.
Why is this happening only when running on a project outside the web-stack's solution, and what can I do to make it runnable everywhere?
The .NET Core Tooling in VS 2017 (< 15.3 preview) / .NET CLI < 2.0 doesn't fully support referencing assemblies on disk. You need to package the library up as a NuGet package or use a project reference ("same solution"). The technical reason is that all the required assemblies and versions are resolved during compilation and written to the .deps.json file. When loading arbitrary assemblies, this might fail because either the assembly or its dependencies cannot be found (or a conflict with each other).
for load the external dll in core project, needed to:
vs 2017 with version 15.3 or upper.
Microsoft.Extensions.DependencyModel NuGet package installed in your project.
I have cloned a solution, it contains multiple projects based on GalaSoft MvvmLight library, also it has two Portable Projects. I have installed all required nuget packages and references but I am not able to build these portable projects and its required to build these portable projects first because all other projects reference it.
I got this(below) error in every file GalaSoft is used. Its a Portable class library project.
Error 64 The type or namespace name 'GalaSoft' could not be found (are
you
missing a using directive or an assembly reference
I have referenced this(below) Portable MvvmLight libraries in this project
\MvvmLightLibs.4.4.32.7\lib\netcore45\GalaSoft.MvvmLight.dll
\MvvmLightLibs.4.4.32.7\lib\netcore45\GalaSoft.MvvmLight.Extras.dll
and here is the platform target
I have tried cleaning and restarting visual studio. I am stuck at this issue for more than 2 days now. Also, I have tried checking and unchecking "Build" option in Configuration Manager (i have read it somewhere) but didnt work.
Also, there are other 44 warnings. All of them looks similar to below warning.
Warning 28 The primary reference "GalaSoft.MvvmLight" could not be
resolved
because it has an indirect dependency on the framework assembly
"System.Linq.Expressions, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently
targeted framework. ".NETPortable,Version=v4.0,Profile=Profile158". To
resolve this problem, either remove the reference "GalaSoft.MvvmLight" or
retarget your application to a framework version which contains
"System.Linq.Expressions, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a".
EDIT:
Question title revised
So your problem is that mvvm light has no package targeting your PCL profile.
When you download the package using nuget install MvvmLightLibs you can see that the package contains the assemblies for only one PCL profile. Mvvm light supports portable-net45+wp8+wpa81+netcore45+monoandroid1+xamarin.ios10. But your PCL targets .NETPortable,Version=v4.5,Profile=Profile78.
If you wan’t your project to be compatible with mvvm light you have to remove the sl5 target.