Azure Notification Hub Client run time error - azure

Downloaded latest Microsoft.Azure.NotificationHubs NuGet package used the NotificationHubClient to create an installation this.HubClient.CreateOrUpdateInstallation(installation);
All the default dependent packages were used when adding the NuGet. When testing I am receiving the following error:
Could not load file or assembly 'Microsoft.Extensions.Options, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I assume this is widely used. How do I get past this?

This is version conflict issue. Remove all your old version package and reinstall Microsoft.Extensions.Options, it will work 👍

Related

Azure DevOps build of Xamarin.iOS project fails - MTOUCH : error MT2002: Failed to resolve "System.Drawing.Color" reference

I have a build issue with a Xamarin.iOS app in Azure DevOps that I haven't been able to solve. I'm wondering if anyone has any suggestions.
Building the iOS version of the app works locally in VS for Mac but fails in Azure due to this error:
MTOUCH : error MT2002: Failed to resolve "System.Drawing.Color" reference from "System.Drawing.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" [/Users/runner/runners/2.164.6/work/1/s/iOS/CatRentalStore.iOS.csproj]
I was having a similar issue with the Android build. I resolved it by switching from the macOS-10.14 hosted build agent to the windows-2019 agent, but that isn't an option with the iOS app.
I've updated packages that may use System.Drawing.Color to the latest stable releases - Acr.UserDialogs, BTProgressHUD, Splat, and Xamarin.Essentials.
I searched the solution source and did not find any direct references to the System.Drawing.Color class.
I also tried specifying the version of Xamarin/Mono to use in the build to match my local version using sudo $AGENT_HOMEDIRECTORY/scripts/select-xamarin-sdk.sh 6_4_0. That caused a different error to occur:
error MSB4018: The "GenerateDepsFile" task failed unexpectedly.
error MSB4018: System.MissingMethodException: Method not found: System.Collections.Generic.IList`1<NuGet.Packaging.Core.PackageDependency> NuGet.ProjectModel.LockFileTargetLibrary.get_Dependencies()
References to this issue:
https://github.com/mono/mono/issues/13483
https://github.com/xamarin/xamarin-macios/pull/6011
https://github.com/aritchie/userdialogs/issues/654
https://github.com/reactiveui/splat/issues/204
According to this document:
NET Core 2.2.105 is default on VM images but Mono version 6.0 or greater requires .NET Core 2.2.300+. If you use the Mono 6.0 or greater, you will have to override .NET Core version using .NET Core Tool Installer task. If you use 6.4.0, you need to install at least 2.2.300+ .net core.
I had the same problem. Visual Studio sometimes failed to update the reference during the NuGet package upgrade:
These steps helped me resolve my issue (iOS project):
Check every reference and see if it matches the version of the corresponding NuGet package
Check the path/version of the referenced assembly:
Make sure that it matches your installed package version:
If the versions do not match: downgrade the corresponding NuGet package and then upgrade the same NuGet package again and check if the version now matches
I did that procedure one NuGet package at a time. After ensuring that all versions match the build succeeded.
On my dev machine, the older versions were still present in the packages folder. Therefore the build always worked on my machine but not on the build server.

Trying to Use System.Diagnostics.Process v4.3 Encounters a v4.1 Not Found Error

I have the "System.Diagnostics.Process" v4.3 NuGet installed but when trying to use one of its functions I encounter a "can't find v4.1" error.
I needed the Nuget. I initially installed v4.1 because I am working on software supporting older OS's, but it was not compatible so I install v4.3 which was compatible with my solution.
I have searched for code/files referencing the library, but none seem to specify it other than the csproject which references the v4.3 version. I have reinstalled the NuGet. I have clean the solution and deleted the bin/obj directories. I have clean the NuGet caches and force a reload. The v4.3 DLL is present in a number of paths/folders, but not v4.1 DLL.
Is there somewhere else that I should look for the specification/path of the lib being used?
Error:
{System.IO.FileNotFoundException: Could not load file or assembly 'System.Diagnostics.Process, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Diagnostics.Process, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at Sentry.CognitiveServices.GetPathWithGetMappedFileName(SafeMemoryMappedViewHandle memoryMappedViewHandle)
at Sentry.CognitiveServices.<SpeakNarrative>d__13.MoveNext()}
Expect V4.3 to be referenced, not v4.1.

Microsoft.SharePoint.Client.Runtime.Portable is missing

I upgraded my site from Kentico 10.0 to 11.0. When I load site then I am getting the following error
Reference.svcmap: Could not load file or assembly
'Microsoft.SharePoint.Client.Runtime.Portable, Version=16.1.0.0,
Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its
dependencies. The system cannot find the file specified.
I installed an SDK package and also tried Install-Package Microsoft.SharePointOnline.CSOM -Version 16.1.7414.1200 but not getting 'Microsoft.SharePoint.Client.Runtime.Portable' dll.
Could you please suggest a solution for me?
Open the NuGet package manager in VS and make sure all projects reference the same version of the Microsoft.SharePointOnline.CSOM package, which should be 16.1.6621.1200 according to the documentation.

How to fix Newtonsoft.Json assembly loading error?

I'm attempting to load a pre-existing Umbraco CMS site into a Visual Studio project and am caught up in a bit of DLL hell.
Here is the error message I get when attempting to compile the site:
Could not load types from assembly Umbraco.Core, Version=1.0.5462.37503, Culture=neutral, PublicKeyToken=null, errors:
Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
File name: 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
I've attempted to re-install Newtonsoft from NuGet, re-install Umbraco from NuGet, delete all DLLs and re-install, removed the Newtonsoft dependentAssembly, every possible solution I've been able to find and this error continues to come up.
Any suggestions?
I'm guessing the binding redirect isn't set up correctly in the web.config file. Try running this in the nuget package manager console:
PM> Get-Project –All | Add-BindingRedirect
This ended up being a bit of a misunderstanding on my part from following the Umbraco videos. I was attempting to set up a new Visual Studio project, import all the DLLs needed, and then move the site content into the project.
All I really needed to do was create a blank project, then move the site content, with all of its DLLs, into the project. This let me immediately start editing the project.
The best solution was to install an earlier version of the package and then upgrade.

How to resolve the c# build warning Found conflicts between different versions of the same dependent assembly

There are multiple warnings for multiple versions of same assembly are getting download at the time of build like mentioned below. Also one more point, most of these assemblies are getting downloaded because of dependencies in the Nuget.
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets (1605): Found conflicts between different versions of the same dependent assembly.
2> There was a conflict between "Ionic.Zip, Version=1.9.1.5, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c" and "Ionic.Zip, Version=1.9.1.8, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c".
2> "Ionic.Zip, Version=1.9.1.5, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c" was chosen because it was primary and "Ionic.Zip, Version=1.9.1.8, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c" was not.
2> References which depend on "Ionic.Zip, Version=1.9.1.5, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c" [C:\TFS\DSCNC\Dev\CatalogServices\Background\packages\DotNetZip.1.9\lib\Ionic.Zip.dll].
One of the way to resolve this issue would be to check in the latest assembly in Packages folder.
Is there any way or configuration setting that we can prevent downloading of multiple versions of same assembly?
As multiple nuget packages could have dependency on different versions of nuget packages. So along with referencing the latest nuget package, you should also add binding redirect to the latest version added for the nuget package, so that other nugets referring to old version of nuget will redirect to latest version & there won't be build warning.

Resources