Microsoft.Web.LibraryManager.Configuration.Settings cannot find Newtonsoft.Json package - asp.net-core

I have a .NET Core 2.2 project setup in Azure DevOps that uses a CI pipeline to build, and recently, after updating the Microsoft.Web.LibraryManager.Build NuGet package to version 2.1.175 the CI pipeline has been throwing the following exception every time I try and run it:
System.TypeInitializationException: The type initializer for 'Microsoft.Web.LibraryManager.Cache.WebRequestHandler' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Microsoft.Web.LibraryManager.Configuration.Settings' threw an exception. ---> System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621)
I've tried installing Newtonsoft.Json NuGet package in the project but am still getting this error.
Is there something I need to be adding to the pipeline, or something that I need added to the project itself to resolve this?

Related

Nhibernate Nunit Framework Exception

I get the error below when running my tests from command line. I use re-sharper for my test environment. When I run from VS2015, all the tests pass. But when I run them from command line using nunit framework the configuration setup fails. My current project is in .NET 4.6.2.
SetUp : System.TypeInitializationException : The type initializer for 'NHibernate.Cfg.Configuration' threw an exception.
System.TypeInitializationException : The type initializer for 'NHibernate.LoggerProvider' threw an exception.
System.ApplicationException : Unable to instantiate: NHibernate.Log4NetLoggerFactory
System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
System.TypeInitializationException : The type initializer for 'NHibernate.Log4NetLoggerFactory' threw an exception.
System.NullReferenceException : Object reference not set to an instance of an object.
at NHibernate.Cfg.Configuration.Reset() in C:\Projects\nhibernate-core\src\NHibernate\Cfg\Configuration.cs:line 177
I encountered this issue when I upgraded from Nhibernate 2.0 to Nhibernate 4.0. I'm able to run the tests using version 2.0 dll of Nhibernate.
I have updated the test framework build file to run the tests on the latest nunit.framework.dll. (not the reference to the test project).

fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0]

While my .NET Core application is running, I noticed the following line:
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0]
An unhandled exception has occurred: Method 'Clone' in type 'Microsoft.EntityFrameworkCore.Infrastructure.Internal.SqlServerOptionsExtension' from assembly 'Microsoft.EntityFrameworkCore.SqlServer, Version=1.1.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation. System.TypeLoadException: Method 'Clone' in type 'Microsoft.EntityFrameworkCore.Infrastructure.Internal.SqlServerOptionsExtension' from assembly 'Microsoft.EntityFrameworkCore.SqlServer, Version=1.1.2.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.
I'm just curious what's causing this error because my apps is still running fine despite the error message.
By the way, I'm using .NET Core 2.0.0 Preview 1 version.
Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware is just the middleware catching exceptions when nothing else in your program did
So your "real" exception is
Method 'Clone' in type 'Microsoft.EntityFrameworkCore.Infrastructure.Internal.SqlServerOptionsExtension' from assembly 'Microsoft.EntityFrameworkCore.SqlServer, ...' does not have an implementation
By doing some googling with this exception, it seems to get down to support of your .Net Core version vs your EF Provider
If you want more information, you can:
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/error-handling?view=aspnetcore-2.1#the-developer-exception-page Enable Developer Exception pages
Log more information from EF (https://learn.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-2.1#add-providers => enable in trace mode will get you more information)

Application Insights failing with System.Reflection.TargetInvocationException on load - WP 8.1

I am starting to explore Application Insights and tried adding it to my Windows Phone 8.1 app. While trying to execute the project, an exception is thrown on load within Public Sub New() in App.xaml.vb. The line where the error happens is
TelemetryClient = new TelemetryClient()
The exception thrown is
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.ni.dll
An exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.ni.dll but was not handled in user code
Additional information: Exception has been thrown by the target of an invocation.
Innerexception details:
{System.InvalidOperationException: Type 'Microsoft.ApplicationInsights.Extensibility.ComponentContextInitializer, Microsoft.ApplicationInsights, Version=0.16.1.418, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not implement the required interface
Microsoft.ApplicationInsights.Extensibility.IContextInitializer.
at Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryConfigurationFactory.CreateInstance(Type interfaceType, String typeName)
at Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryConfigurationFactory.LoadInstance(XElement definition, Type expectedType, Object instance)
at Microsoft.ApplicationInsights.Extensibility.Implementation.TelemetryConfigurationFactory.LoadInstances[T](XElement definition, ICollection`1 instances)}
I followed the steps outlined in the Azure documentation. What may I be doing wrong?
Are you using a Windows Phone app on top of Windows Runtime or on top of Silverlight?
If you remove the following line from ApplicationInsights.config, does your app start successfully?
<Add Type="Microsoft.ApplicationInsights.Extensibility.ComponentContextInitializer, Microsoft.ApplicationInsights"/>
Turns out it was a corrupted solution. I had added the nuget and then added the Application Insights. In between I had upgraded the nugget package to the 0.16 pre-release version. In effect it had created multiple references. So I ended up manually clearing all entries of Microsoft.ApplicationInsights in package.config and .vbproj. I also removed all the references and referenced the whole thing again. Now it works like a charm!

MissingMethodException with xsp4 and asp.net 4.5

I am trying to test a web site with xsp4, all assemblies are compiled for target framework 4.5. I get the following stack trace.
Exception during TraceManager initialization:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Web.Configuration.TraceSection ---> System.MissingMethodException: Method not found: 'System.Configuration.ConfigurationProperty..ctor'.
--- End of inner exception stack trace ---
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
A search here on stackoverflow (and other places) found that a possible reason is that xsp4 runs within the 4.0 directory of mono. Mine is already located in 4.5 and is used by the xsp script, so I am stuck with this one. Any ideas?
Found it. The error resulted from having a FSharp.Core.Dll within the bin folder. It is a mixed F# / C# project and a local copy is not needed, if the Dll resides within the GAC. Removing it made the error disappear.

Strange error while attempting to use Zip task from .net 4.0 version of MSBuild.ExtensionPack

We've been getting inconsistent results from the Zip task in Tigris MSBuild task library, so we're trying to use the Zip task in the MSBuild.ExtensionPack for .NET 4.0. But when we execute this new Zip task, we get the following error from the MSBuild executable:
C:\development\build\PrepareLastKnownGood.csproj(40,3): error : Typ
eInitializationException: The type initializer for 'java.lang.System' threw an
exception.\r
C:\development\build\PrepareLastKnownGood.csproj(40,3): error : Unsat
isfiedLinkError: Unable to load DLL 'vjsnativ': The specified module could not
be found. (Exception from HRESULT: 0x8007007E)\r
Has anyone else encountered this error in their use of the Zip task from MSBuild.ExtensionPack? If so, how did you resolve it?
Zip task from MSBuild.ExtensionPack.JSharp.dll is implemented in J#. And has dependency to the vjslib.dll.
You need to install Microsoft Visual J# Version 2.0 Redistributable Package.