Nhibernate Nunit Framework Exception - nhibernate

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).

Related

Microsoft.Web.LibraryManager.Configuration.Settings cannot find Newtonsoft.Json package

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?

Apache Ignite .Net Core failed to start

Apache ignite .net core server node fails to start with below error, any idea what could be the reason?
Apache.Ignite.Core.Binary.BinaryObjectException
HResult = -2146233088,
Message = Unexpected field type [pos=42559, expected=String, actual=0]
StackTrace:
class org.apache.ignite.binary.BinaryObjectException: Unexpected field type [pos=42559, expected=String, actual=0]
at org.apache.ignite.internal.binary.BinaryReaderExImpl.checkFlagNoHandles(BinaryReaderExImpl.java:1684)
at org.apache.ignite.internal.binary.BinaryReaderExImpl.readString(BinaryReaderExImpl.java:1058)
at org.apache.ignite.internal.processors.platform.utils.PlatformConfigurationUtils.readDataRegionConfiguration(PlatformConfigurationUtils.java:2303)
at org.apache.ignite.internal.processors.platform.utils.PlatformConfigurationUtils.readDataStorageConfiguration(PlatformConfigurationUtils.java:2082)
at org.apache.ignite.internal.processors.platform.utils.PlatformConfigurationUtils.readIgniteConfiguration(PlatformConfigurationUtils.java:919)
at org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetConfigurationClosure.processPrepareResult(PlatformDotNetConfigurationClosure.java:195)
at org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetConfigurationClosure.prepare(PlatformDotNetConfigurationClosure.java:182)
at org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetConfigurationClosure.apply0(PlatformDotNetConfigurationClosure.java:110)
at org.apache.ignite.internal.processors.platform.PlatformAbstractConfigurationClosure.apply(PlatformAbstractConfigurationClosure.java:50)
at org.apache.ignite.internal.processors.platform.PlatformAbstractConfigurationClosure.apply(PlatformAbstractConfigurationClosure.java:27)
at org.apache.ignite.internal.processors.platform.PlatformAbstractBootstrap.start(PlatformAbstractBootstrap.java:40)
at org.apache.ignite.internal.processors.platform.PlatformIgnition.start(PlatformIgnition.java:74)
NOTE:This error only occuring in Apache Ignite 2.12.0 and code working fine in the previous versions.
An error like this happens due to a mismatch of .NET binaries and Java jar files.
Try deleting bin and obj directories and performing a clean rebuild.

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)

Compiling error when generating moles for System.dll, System.Xml.dll in .NET4

There are compiling errors when generating moles for .NET4 System.dll (build 4.0.30310.261) and System.Xml.Dll(build 4.0.30319.233). The errors for System.Dll are:
m.g.cs(251449,33): error CS0115: 'System.Net.Moles.SFileWebResponse.Dispose(bool)': no suitable method found to override [c:\jin\moles\tmp\s\m.g.csproj]
m.g.cs(251650,30): error CS0115: 'System.Net.Moles.SFileWebResponse.SupportsHeaders': no suitable method found to override [c:\jin\moles\tmp\s\m.g.csproj]
m.g.cs(255339,33): error CS0115: 'System.Net.Moles.SHttpWebResponse.Dispose(bool)': no suitable method found to override [c:\jin\moles\tmp\s\m.g.csproj]
m.g.cs(255540,30): error CS0115: 'System.Net.Moles.SHttpWebResponse.SupportsHeaders': no suitable method found to override [c:\jin\moles\tmp\s\m.g.csproj]
m.g.cs(303198,33): error CS0115: 'System.Net.Moles.SWebResponse.Dispose(bool)': no suitable method found to override [c:\jin\moles\tmp\s\m.g.csproj]
m.g.cs(303399,30): error CS0115: 'System.Net.Moles.SWebResponse.SupportsHeaders': no suitable method found to override [c:\jin\moles\tmp\s\m.g.csproj]
Done Building Project "c:\jin\moles\tmp\s\m.g.csproj" (default targets) -- FAILED.
The errors for System.Xml.Dll are:
m.g.cs(113977,17): error CS0205: Cannot call an abstract base member: 'System.Xml.XmlReader.Close()' [c:\jin\moles\tmp\s\m.g.csproj]
m.g.cs(116149,21): error CS0205: Cannot call an abstract base member: 'System.Xml.XmlResolver.Credentials.set' [c:\jin\moles\tmp\s\m.g.csproj]
m.g.cs(130559,17): error CS0205: Cannot call an abstract base member: 'System.Xml.XmlWriter.Close()' [c:\jin\moles\tmp\s\m.g.csproj]
I'm using Moles 0.94 with VS2010. The errors only happen for newer version of the two DLLs, after .NET 4 service pack is installed. Moles are generated fine for version 4.0.30319.1 of the two DLL, before .NET 4 service packs.
It seems the code generated by Moles is not compatible with latest .NET4 assemblies.
See these questions:
Moling System.dll
http://social.msdn.microsoft.com/Forums/en/pex/thread/446669dd-1d69-4020-9174-dc259a55b4b4
Basically, update System.moles as follows:
<Moles xmlns="http://schemas.microsoft.com/moles/2010/">
<Assembly Name="System" ReflectionOnly="true"/>
</Moles>

Error testing ejb 3.1 (netbeans-glassifish-junit4)

I'm trying to unit testing a EJB with entity crud operations. I already was capable of testing it just running my web application (and all works), but I want to do it with JUnit.
So, my environment is Netbeans 7, Glassfish 3.1 (JavaDB, EclipseLink), JUnit4.
When I create a test class for my EJB, the code template uses the following line of code that throw an exception when I run the code:
EJBContainer container = javax.ejb.embeddable.EJBContainer.createEJBContainer();
the exception is:
java.lang.RuntimeException: Invalid resource : jdbc/mine__pm
Exception while preparing the app : Invalid resource : jdbc/mine__pm
My EJB has an injected EntityManager that points to my persistence unit. This persistence unit is referencing a data source that I JNDI named jdbc/mine created by Netbeans for my Glassfish. It runs and I can see it on my server. I tried using a glassfish-resource.xml to do the same thing too.
Why doesn't it work?