System.Drawing mono failure debugging - c#

As per this answer regarding failed mono-test-install results, I put the following in test.cs:
using System;
using System.Drawing;
class X {
static void Main ()
{
Bitmap b = new Bitmap (100, 100);
}
}
Then ran
mcs -pkg:dotnet test.cs
output:
test.cs(7,16): warning CS0219: The variable `b' is assigned but its
value is never used Compilation succeeded - 1 warning(s)
And ran the resulting exe with:
mono test.exe
output:
Unhandled Exception:
System.TypeInitializationException: An exception was thrown by the type initializer for System.Drawing.GDIPlus ---> System.DllNotFoundException: /usr/local/lib/libgdiplus.so
at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
at System.Drawing.GDIPlus..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Drawing.Bitmap..ctor (Int32 width, Int32 height, PixelFormat format) [0x00000] in <filename unknown>:0
at System.Drawing.Bitmap..ctor (Int32 width, Int32 height) [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap:.ctor (int,int)
at X.Main () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for System.Drawing.GDIPlus ---> System.DllNotFoundException: /usr/local/lib/libgdiplus.so
at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
at System.Drawing.GDIPlus..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Drawing.Bitmap..ctor (Int32 width, Int32 height, PixelFormat format) [0x00000] in <filename unknown>:0
at System.Drawing.Bitmap..ctor (Int32 width, Int32 height) [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap:.ctor (int,int)
at X.Main () [0x00000] in <filename unknown>:0
Is it safe to ignore this or should I be debugging the line NotFoundException: /usr/local/lib/libgdiplus.so next?

Thanks Jon, I'd just found that page and though I didn't follow it verbatim, I put a symlink in as:
sudo ln -s /usr/lib/libgdiplus.so /usr/local/lib/libgdiplus.so
Which resolved the errors and now mono-test-install returns:
Your have a working System.Drawing setup
Besides the grammatical issues, it should be resolved.

Related

Mono compiler // Terminal emulator issue

I get this error when I try to compile csharp or fsharp files. This happens when using gnome terminal or jetbrain rider.
It works fine in tty or termials like xterm and urxvt.
Also I am able to compile c, c++ and go code.
Btw, I am using Arch/Antergos and got this issue yesterday.
Unhandled Exception:
System.TypeInitializationException: The type initializer for 'System.Console' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.ConsoleDriver' threw an exception. ---> System.Exception: Magic number is wrong: 542
at System.TermInfoReader.ReadHeader (System.Byte[] buffer, System.Int32& position) [0x00028] in :0
at System.TermInfoReader..ctor (System.String term, System.String filename) [0x0005f] in :0
at System.TermInfoDriver..ctor (System.String term) [0x00055] in :0
at System.ConsoleDriver.CreateTermInfoDriver (System.String term) [0x00000] in :0
at System.ConsoleDriver..cctor () [0x0004d] in :0
--- End of inner exception stack trace ---
at System.Console.SetupStreams (System.Text.Encoding inputEncoding, System.Text.Encoding outputEncoding) [0x00007] in :0
at System.Console..cctor () [0x0008e] in :0
--- End of inner exception stack trace ---
at Mono.CSharp.Driver.Main (System.String[] args) [0x00019] in <2b1e99ce45b54209bdcdab138d9758ae>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'System.Console' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.ConsoleDriver' threw an exception. ---> System.Exception: Magic number is wrong: 542
at System.TermInfoReader.ReadHeader (System.Byte[] buffer, System.Int32& position) [0x00028] in :0
at System.TermInfoReader..ctor (System.String term, System.String filename) [0x0005f] in :0
at System.TermInfoDriver..ctor (System.String term) [0x00055] in :0
at System.ConsoleDriver.CreateTermInfoDriver (System.String term) [0x00000] in :0
at System.ConsoleDriver..cctor () [0x0004d] in :0
--- End of inner exception stack trace ---
at System.Console.SetupStreams (System.Text.Encoding inputEncoding, System.Text.Encoding outputEncoding) [0x00007] in :0
at System.Console..cctor () [0x0008e] in :0
--- End of inner exception stack trace ---
at Mono.CSharp.Driver.Main (System.String[] args) [0x00019] in <2b1e99ce45b54209bdcdab138d9758ae>:0

ADAL: Error with getting token on specific machine

I have a C# app written for pushing some data to MS service (PowerBI) using ADAL for authentication. I have created and compiled it using Mono on Debian Jessie (trying to get as close to production environment as possible). It runs perfectly on this machine but when I move it to production I get an error Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException: user_realm_discovery_failed: User realm discovery failed. I have read it might be connected to defaultProxy setting in machine.config so I modified my code accordingly but it didn't help. Main differences between production server and my machine are:
Command line only (prod) -> GNOME, Static IP -> Dynamic IP. Both are virtual machines. The full error output:
Unhandled Exception:
Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException: user_realm_discovery_failed: User realm discovery failed ---> System.Net.WebException: Error getting response stream (Write: failed.): SendFailure ---> System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: Invalid certificate received from server. Error code
at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.RemoteValidation (Mono.Security.Protocol.Tls.ClientContext context, AlertDescription description) [0x00000] in <filename unk
at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.validateCertificates (Mono.Security.X509.X509CertificateCollection certificates) [0x00000] in <filename unknown>:0
at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.ProcessAsTls1 () [0x00000] in <filename unknown>:0
at Mono.Security.Protocol.Tls.Handshake.HandshakeMessage.Process () [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) Mono.Security.Protocol.Tls.Handshake.HandshakeMessage:Process ()
at Mono.Security.Protocol.Tls.ClientRecordProtocol.ProcessHandshakeMessage (Mono.Security.Protocol.Tls.TlsStream handMsg) [0x00000] in <filename unknown>:0
at Mono.Security.Protocol.Tls.RecordProtocol.InternalReceiveRecordCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0
at Microsoft.IdentityModel.Clients.ActiveDirectory.HttpWebRequestWrapper+<GetResponseSyncOrAsync>d__2.MoveNext () [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter`1[Microsoft.IdentityModel.Clients.ActiveDirectory.IHttpWebResponse].GetResult () [0x00000] in <filename unknown>:0
at Microsoft.IdentityModel.Clients.ActiveDirectory.UserRealmDiscoveryResponse+<CreateByDiscoveryAsync>d__0.MoveNext () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at Microsoft.IdentityModel.Clients.ActiveDirectory.UserRealmDiscoveryResponse+<CreateByDiscoveryAsync>d__0.MoveNext () [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter`1[Microsoft.IdentityModel.Clients.ActiveDirectory.UserRealmDiscoveryResponse].GetResult () [0x00000] in <filename unknown>:0
at Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenNonInteractiveHandler+<PreTokenRequest>d__4.MoveNext () [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0
at Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenHandlerBase+<RunAsync>d__0.MoveNext () [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter`1[Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult].GetResult () [0x00000] in <filename unknown>:0
at Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext+<AcquireTokenCommonAsync>d__0.MoveNext () [0x00000] in <filename unknown>:0
ErrorCode: user_realm_discovery_failed
StatusCode: 0
[ERROR] FATAL UNHANDLED EXCEPTION: Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException: user_realm_discovery_failed: User realm discovery failed ---> System.Net.WebException: Erhe authentication or decryption has failed.): SendFailure ---> System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: Invalid certifica0xffffffff800b010a
at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.RemoteValidation (Mono.Security.Protocol.Tls.ClientContext context, AlertDescription description) [0x00000] in <filename unk
at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.validateCertificates (Mono.Security.X509.X509CertificateCollection certificates) [0x00000] in <filename unknown>:0
at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.ProcessAsTls1 () [0x00000] in <filename unknown>:0
at Mono.Security.Protocol.Tls.Handshake.HandshakeMessage.Process () [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) Mono.Security.Protocol.Tls.Handshake.HandshakeMessage:Process ()
at Mono.Security.Protocol.Tls.ClientRecordProtocol.ProcessHandshakeMessage (Mono.Security.Protocol.Tls.TlsStream handMsg) [0x00000] in <filename unknown>:0
at Mono.Security.Protocol.Tls.RecordProtocol.InternalReceiveRecordCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0
at Microsoft.IdentityModel.Clients.ActiveDirectory.HttpWebRequestWrapper+<GetResponseSyncOrAsync>d__2.MoveNext () [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter`1[Microsoft.IdentityModel.Clients.ActiveDirectory.IHttpWebResponse].GetResult () [0x00000] in <filename unknown>:0
at Microsoft.IdentityModel.Clients.ActiveDirectory.UserRealmDiscoveryResponse+<CreateByDiscoveryAsync>d__0.MoveNext () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at Microsoft.IdentityModel.Clients.ActiveDirectory.UserRealmDiscoveryResponse+<CreateByDiscoveryAsync>d__0.MoveNext () [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter`1[Microsoft.IdentityModel.Clients.ActiveDirectory.UserRealmDiscoveryResponse].GetResult () [0x00000] in <filename unknown>:0
at Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenNonInteractiveHandler+<PreTokenRequest>d__4.MoveNext () [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <filename unknown>:0
at Microsoft.IdentityModel.Clients.ActiveDirectory.AcquireTokenHandlerBase+<RunAsync>d__0.MoveNext () [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter`1[Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult].GetResult () [0x00000] in <filename unknown>:0
at Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext+<AcquireTokenCommonAsync>d__0.MoveNext () [0x00000] in <filename unknown>:0
ErrorCode: user_realm_discovery_failed
StatusCode: 0
All the references to <filename unknown>:0 are not helpful either.
EDIT: I have also tried compiling it on the production machine - same error when trying to run
I have figured it out myself, quite stupid mistake. I installed mono from default debian repos and they were outdated. I have actually thought about it and added xamarin up-to-date repos, but I didn't notice that on apt-get upgrade the mono packages got kept back. apt-get distro-upgrade fixed it all. Just have to be careful with this command - can mess up your system.

Chat Server Mysql error

When i try to start the server i got everytime the same error.
i searched here for a solution and found something that i have to edit my connection string. After this im get the same error again
Sorry for my bad english
`RRChatServer.exe
Unhandled Exception: System.EntryPointNotFoundException:
CreateSemaphore at (wrapper managed-to-native)
MySql.Data.Common.Semaphore:CreateSemaphore
(MySql.Data.Common.SECURITY_ATTRIBUTES&,int,int,string) at
MySql.Data.Common.Semaphore..ctor (Int32 initialCount, Int32
maximumCount) [0x00000] in :0 at (wrapper
remoting-invoke-with-check) MySql.Data.Common.Semaphore:.ctor
(int,int) at MySql.Data.MySqlClient.MySqlPool..ctor
(MySql.Data.MySqlClient.MySqlConnectionString settings) [0x00000] in
:0 at
MySql.Data.MySqlClient.MySqlPoolManager.GetPool
(MySql.Data.MySqlClient.MySqlConnectionString settings) [0x00000] in
:0 at MySql.Data.MySqlClient.MySqlConnection.Open
() [0x00000] in :0 [ERROR] FATAL UNHANDLED
EXCEPTION: System.EntryPointNotFoundException: CreateSemaphore at
(wrapper managed-to-native)
MySql.Data.Common.Semaphore:CreateSemaphore
(MySql.Data.Common.SECURITY_ATTRIBUTES&,int,int,string) at
MySql.Data.Common.Semaphore..ctor (Int32 initialCount, Int32
maximumCount) [0x00000] in :0 at (wrapper
remoting-invoke-with-check) MySql.Data.Common.Semaphore:.ctor
(int,int) at MySql.Data.MySqlClient.MySqlPool..ctor
(MySql.Data.MySqlClient.MySqlConnectionString settings) [0x00000] in
:0 at
MySql.Data.MySqlClient.MySqlPoolManager.GetPool
(MySql.Data.MySqlClient.MySqlConnectionString settings) [0x00000] in
:0 at MySql.Data.MySqlClient.MySqlConnection.Open
() [0x00000] in :0`

HelloWorld is successfully launched by Windows .NET but not by MONO

I've installed mono on my 64-bit Windows 7 using:
mono-3.2.3-gtksharp-2.12.11-win32-0.exe
from go-mono download page
in directory (without spaces in path) changed according to Jim Gomes' advice
Successfully run first two examples
Console Hello World
Gtk# Hello World
from Mono Basics article.
But the 3d example "WinForms Hello World" is compiled without errors and run from Windows (by double-clicking in Windows Explorer) successfully but running:
mono hello.exe
from "Mono-3.2.3 Command Prompt" window produces the errors listed below
(note that first two examples including a window of second example was launched successfully from command prompt invoking through mono ...)
What is the problem and how to overcome it?
UPDATE
According to mentioned article "Mono Basics" I compiled the 3d example "Winforms Hello World" with gmcs hello.cs -pkg:dotnet.
BTW, where is that dotnet package located?
Is it in directory with the same name? I do not have a single dir with exactly such name dotnet under Mono-3.2.3 dir
The errors produced by running mono hello.exe from "Mono-3.2.3 Command Prompt"
Unhandled Exception:
System.TypeInitializationException:
An exception was thrown by the type initializer for
System.Windows.Forms.WindowsFormsSynchronizationContext
---> System.TypeInitializationException:
An exception was thrown by the type initializer for
System.Windows.Forms.ThemeEngine ---> System.TypeInitializationException:
An exception was thrown by the type initializer for
System.Windows.Forms.ThemeWin32Classic
---> System.TypeInitializationException:
An exception was thrown by the type initializer for System.Drawing.KnownColors
---> System.TypeInitializationException:
An exception was thrown by the type initializer for System.Drawing.GDIPlus
---> System.DllNotFoundException: /tmp/install/lib/libgdiplus.so at
(wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup
(ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
at System.Drawing.GDIPlus..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Drawing.KnownColors..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Drawing.Color.get_Black () [0x00000] in <filename unknown>:0
at System.Windows.Forms.ThemeWin32Classic..cctor () [0x00000] in <filename unk
nown>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.ThemeEngine..cctor () [0x00000] in <filename unknown>:
0
--- End of inner exception stack trace ---
at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () [0x0
0000] in <filename unknown>:0
at System.Windows.Forms.Control..ctor () [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
at System.Windows.Forms.WindowsFormsSynchronizationContext..cctor () [0x00000]
in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.Control..ctor () [0x00000] in <filename unknown>:0
at System.Windows.Forms.ScrollableControl..ctor () [0x00000] in <filename unkn own>:0
at System.Windows.Forms.ContainerControl..ctor () [0x00000] in <filename unkno wn>:0
at System.Windows.Forms.Form..ctor () [0x00000] in <filename unknown>:0
at HelloWorld..ctor () [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) HelloWorld:.ctor ()
at HelloWorld.Main () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException:
An exception was thrown by the type initializer for
System.Windows.Forms.WindowsFormsSynchronizationContext
---> System.TypeInitializationException:
An exception was thrown by the type initializer for
System.Windows.Forms.ThemeEngine
---> System.TypeInitializationException:
An exception was thrown by the type initializer for
System.Windows.Forms.ThemeWin32Classic
---> System.TypeInitializationException:
An exception was thrown by the type initializer for
System.Drawing.KnownColors
---> System.TypeInitializationException:
An exception was thrown by the type initializer for
System.Drawing.GDIPlus
---> System.DllNotFoundException: /tmp/install/lib/libgdiplus.so
at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
at System.Drawing.GDIPlus..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Drawing.KnownColors..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Drawing.Color.get_Black () [0x00000] in <filename unknown>:0
at System.Windows.Forms.ThemeWin32Classic..cctor () [0x00000] in <filename unk
nown>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.ThemeEngine..cctor () [0x00000] in <filename unknown>:
0
--- End of inner exception stack trace ---
at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () [0x0
0000] in <filename unknown>:0
at System.Windows.Forms.Control..ctor () [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
at System.Windows.Forms.WindowsFormsSynchronizationContext..cctor () [0x00000]
in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.Control..ctor () [0x00000] in <filename unknown>:0
at System.Windows.Forms.ScrollableControl..ctor () [0x00000] in <filename unkn
own>:0
at System.Windows.Forms.ContainerControl..ctor () [0x00000] in <filename unkno
wn>:0
at System.Windows.Forms.Form..ctor () [0x00000] in <filename unknown>:0
at HelloWorld..ctor () [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) HelloWorld:.ctor ()
at HelloWorld.Main () [0x00000] in <filename unknown>:0
I have encountered this problem.
I think this is mono's bug.
If you installed mono in C:\Program Files (x86)\Mono-3.2.3\etc\mono
Find the file C:\Program Files (x86)\Mono-3.2.3\etc\mono\config
Change Line 29-30:
<dllmap dll="gdiplus" target="/tmp/install/lib/libgdiplus.so" />
<dllmap dll="gdiplus.dll" target="/tmp/install/lib/libgdiplus.so" />
To:
<dllmap dll="gdiplus" target="/tmp/install/lib/libgdiplus.so" os="!windows" />
<dllmap dll="gdiplus.dll" target="/tmp/install/lib/libgdiplus.so" os="!windows" />
And this problem will be solved.

NHibernate throws TypeLoadException under mono

I have a .Net based command line app that interacts (CRUD) with PostgreSQL 9.1. Using Nuget, the project currently references NHibernate 3.2.0.4000 and FluentHibenrate 1.3.0.717
Now the code runs fine under .Net environment (meaning Windows Xp/7), but under Mono (Mono JIT compiler version 2.10.8.1 (Debian 2.10.8.1-1ubuntu2.2)), I am seeing TypeLoadException within NHibernate from the exact same code (I did not re-compile anything for mono.). Can someone help and point the way? Thanks!
Here is the stack trace
FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
---> FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
---> NHibernate.MappingException: Could not compile the mapping document: (XmlDocument) ---> System.TypeInitializationException: An exception was thrown by the type initializer for NHibernate.Dialect.Dialect ---> System.TypeLoadException: Could not load type 'NHibernate.Dialect.Dialect+NoOpViolatedConstraintNameExtracter' from assembly 'NHibernate, Version=3.2.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4'.
--- End of inner exception stack trace ---
at NHibernate.Cfg.Configuration.AddDeserializedMapping (NHibernate.Cfg.MappingSchema.HbmMapping mappingDocument, System.String documentFileName) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at NHibernate.Cfg.Configuration.LogAndThrow (System.Exception exception) [0x00000] in <filename unknown>:0
at NHibernate.Cfg.Configuration.AddDeserializedMapping (NHibernate.Cfg.MappingSchema.HbmMapping mappingDocument, System.String documentFileName) [0x00000] in <filename unknown>:0
at NHibernate.Cfg.Configuration.AddValidatedDocument (NHibernate.Cfg.NamedXmlDocument doc) [0x00000] in <filename unknown>:0
at NHibernate.Cfg.Configuration.ProcessMappingsQueue () [0x00000] in <filename unknown>:0
at NHibernate.Cfg.Configuration.AddDocumentThroughQueue (NHibernate.Cfg.NamedXmlDocument document) [0x00000] in <filename unknown>:0
at NHibernate.Cfg.Configuration.AddXmlReader (System.Xml.XmlReader hbmReader, System.String name) [0x00000] in <filename unknown>:0
at NHibernate.Cfg.Configuration.AddInputStream (System.IO.Stream xmlInputStream, System.String name) [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration () [0x00000] in <filename unknown>:0
at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory () [0x00000] in <filename unknown>:0
at MyProj.Repository.FluentNHibernateHelperPostgreSQL.CreateSessionFactory () [0x00000] in <filename unknown>:0
at MyProj.Repository.FluentNHibernateHelperPostgreSQL.get_SessionFactory () [0x00000] in <filename unknown>:0
at MyProj.Repository.FluentNHibernateHelperPostgreSQL.OpenSession () [0x00000] in <filename unknown>:0
at MyProj.Repository.NHibernateSessionHelper.SmartSessionFactory () [0x00000] in <filename unknown>:0
at MyProj.Repository.NHibernateSessionHelper.DoAnything (MyProj.Repository.TargetMethod target) [0x00000] in <filename unknown>:0
at MyProj.Program+<>c__DisplayClass10.<RetrieveDataDriver>b__a () [0x00000] in <filename unknown>:0
Here is the relevant code for FluentNHibernateHelperPostgreSQL.CreateSessionFactory ()
private static ISessionFactory CreateSessionFactory()
{
FluentConfiguration fluentConfiguration = Fluently.Configure();
PostgreSQLConfiguration standard = PostgreSQLConfiguration.Standard;
FluentConfiguration fluentConfiguration1 = fluentConfiguration.Database(((PersistenceConfiguration<PostgreSQLConfiguration, PostgreSQLConnectionStringBuilder>)standard).ConnectionString((PostgreSQLConnectionStringBuilder c) => c.FromConnectionStringWithKey("ConnectionStringKey")));
ISessionFactory sessionFactory = fluentConfiguration1.Mappings((MappingConfiguration m) => m.AutoMappings.Add(FluentNHibernateHelperPostgreSQL.CreateAutomappings)).ExposeConfiguration(FluentNHibernateHelperPostgreSQL.BuildSchema).BuildSessionFactory();
return sessionFactory;
}
The solution was to manually deploy the latest Mono package from go-mono.com
As suggested by knocte in the comment section, 2.11.4 solved the problem.
I haven't tried 3.x, but so far, I have been happy 2.11.x with no reason to jump into 3.x ship yet.

Categories

Resources