NHibernate on Mono running ASP.NET MVC 3 web application - asp.net-mvc-3

I am having issues with NHibernate on Mono (Ubuntu server 13.04)
Mono version:
Mono JIT compiler version 3.2.1 ((no/f3f789e Wed Aug 21 17:40:25 UTC 2013)
Copyright (C) 2002-2012 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen
I get this exception:
System.InvalidProgramException
Invalid IL code in System.Data.Common.DbProviderFactories:GetFactory (string): method body is empty.
Details:
Non-web exception. Exception origin (name of application or object): NHibernate.
Exception Stack Trace:
at NHibernate.Driver.ReflectionBasedDriver..ctor (System.String providerInvariantName, System.String driverAssemblyName, System.String connectionTypeName, System.String commandTypeName) [0x00000] in <filename unknown>:0
at NHibernate.Driver.NpgsqlDriver..ctor () [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00000] in <filename unknown>:0
The code where I get the exception looks like this:
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
//NpgsqlEventLog.Level = LogLevel.Debug;
//NpgsqlEventLog.LogName = "NpgsqlTests.LogFile";
SessionFactory = Fluently.Configure().Database(FluentNHibernate.Cfg.Db.PostgreSQLConfiguration.Standard.
ConnectionString(c =>
c.Host("localhost")
.Database("newtest")
.Username("postgres")
.Password("******")
.Port(5432)
)).Mappings(m =>
m.FluentMappings.AddFromAssemblyOf<Entity>())
.ExposeConfiguration(c => c.SetProperty("current_session_context_class", "web"))
.BuildSessionFactory();
}

I solved my issue by removing unwanted references in Web.Config file. There still was an configuration section for Entity Framework, even if I had removed it with NuGet.
When all these unwanted dll references were removed in Web.Config, the project ran as it should in mono environment, so the errors I mentioned in my initial entry is a bit misleading as the issues had nothing to do with NHibernate.

Related

TypeLoadException in Xamarin.Forms project without TypeName

I'm working on a simple ProjectOxford Face and Emotion APIs demo with Xamarin.Forms
I added the Face and Emotion APIs from Nuget to the PCL Forms project and all platform-specific projects I get a TypeLoadException but the TypeName property is empty, so I don't know what's not loading.
The "Link Behavior" setting in the iOS project is "Don't Link" and the app runs in the simulator, selects a picture but when it hits the method that is supposed to send it to Face and Emotion APIs I get the exception below.
System.TypeLoadException: Failure has occurred while loading a type.
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00031] in /Library/Frameworks/Xamarin.iOS.framework/Versions/9.9.0.719/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:316
at HelloForms.FaceViewModel.DoAnalyzePhoto () [0x0000f] in <filename unknown>:0
at HelloForms.FaceViewModel+<FaceViewModel>c__async8.MoveNext () [0x00021] in .../HelloForms/XPlat/HelloForms/ViewModels/FaceViewModel.cs:115
at --- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/9.9.0.719/src/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>m__0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/9.9.0.719/src/mono/external/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1018
at UIKit.UIKitSynchronizationContext+<Post>c__AnonStorey0.<>m__0 () [0x00000] in /Users/builder/data/lanes/1381/3afb4af5/source/maccore/src/UIKit/UIKitSynchronizationContext.cs:24
at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Users/builder/data/lanes/1381/3afb4af5/source/maccore/src/Foundation/NSAction.cs:163
at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/1381/3afb4af5/source/maccore/src/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/1381/3afb4af5/source/maccore/src/UIKit/UIApplication.cs:63
at HelloForms.iOS.Application.Main (System.String[] args) [0x00008] in .../HelloForms/XPlat/iOS/Main.cs:17

MvvmCross crashes on app start with "Method 'Array.Empty' not found" exception

I have recently updated my Xamarin.Android app MvvmCross package from 4.1.4 to 4.1.5 and now unable to launch my app. Couldn't even debug the issue as long as my code doesn't get any control before the crash.
System.MissingMethodException: Method 'Array.Empty' not found.
at MvvmCross.Droid.Views.MvxActivityViewExtensions.OnViewCreate (IMvxAndroidView androidView, Android.OS.Bundle bundle) [0x00055] in <filename unknown>:0
at MvvmCross.Droid.Views.MvxActivityAdapter.EventSourceOnCreateCalled (System.Object sender, MvvmCross.Platform.Core.MvxValueEventArgs`1 eventArgs) [0x0000c] in <filename unknown>:0
at at (wrapper delegate-invoke) System.EventHandler`1[MvvmCross.Platform.Core.MvxValueEventArgs`1[Android.OS.Bundle]]:invoke_void_object_TEventArgs (object,MvvmCross.Platform.Core.MvxValueEventArgs`1<Android.OS.Bundle>)
at MvvmCross.Platform.Core.MvxDelegateExtensionMethods.Raise[T] (System.EventHandler`1 eventHandler, System.Object sender, MvvmCross.Platform.Core.T value) [0x00000] in C:\vcs\git\MvvmCross\MvvmCross\Platform\Platform\Core\MvxDelegateExtensionMethods.cs:21
at MvvmCross.Platform.Droid.Views.MvxEventSourceActivity.OnCreate (Android.OS.Bundle bundle) [0x00014] in <filename unknown>:0
at MvvmCross.Droid.Views.MvxSplashScreenActivity.OnCreate (Android.OS.Bundle bundle) [0x00017] in <filename unknown>:0
at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) [0x00011] in /Users/builder/data/lanes/3236/ee215fc9/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.App.Activity.cs:2857
at at (wrapper dynamic-method) System.Object:97318edf-ae39-4dd0-a17c-810218756b0b (intptr,intptr,intptr)
clean / rebuild doesn't help
rollback to 4.1.4 restores the app
This seems to be a current issue with MVVMCross and Mono. More information about it here: https://github.com/MvvmCross/MvvmCross/issues/1330

Gtk Application Non-Consistant Execution using Xamarin Theme

I have a mkbundled mono app with mono embedded in it.i have created a standalone package from it using platypus.I use the following to load the Mac Theme(Xamarin)
Gtk.Rc.Parse ("Default/gtkrc");
The theme is the Xamarin theme from share/theme/xamarin
The thing is that the application does not launch consitantly when using this theme.It launches randomly.Also im using gtk-button-images = 1 in theme file to show the buttons.The app works fine with other themes.
What is the problem here?please help.
UPDATE:
I have tried launching the application manually from console by putting
the following ./script.sh
It launches the program sometimes. Otherwise the console stays there with no output.I have the program window icon on the dock during this ,When i close it i can see the following output on the console
./script.sh: line 3: 830 Terminated: 15 ./myapp
The contents in the script are as follows
VAR=`pwd`
export DYLD_FALLBACK_LIBRARY_PATH="$VAR/lib:/usr/lib"
./myapp
On Random successful execution of the program and only upon closing the program.I get the following on the console
Gtk-WARNING **: Can't set a parent on a toplevel widget
Unhandled Exception:
System.MissingMethodException: No constructor found for MonoMac.Foundation.NSObject+MonoMac_Disposer::.ctor(System.IntPtr)
at System.Activator.CreateInstance (System.Type type, BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x00000] in <filename unknown>:0
at System.Activator.CreateInstance (System.Type type, System.Object[] args, System.Object[] activationAttributes) [0x00000] in <filename unknown>:0
at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in <filename unknown>:0
at MonoMac.ObjCRuntime.Runtime.GetNSObject (IntPtr ptr) [0x00000] in <filename unknown>:0
at MonoMac.ObjCRuntime.NSObjectMarshaler`1[MonoMac.Foundation.NSObject].MarshalNativeToManaged (IntPtr handle) [0x00000] in <filename unknown>:0
at (wrapper native-to-managed) object:[MonoMac.Foundation.NSObject:IntPtr NativeRetain()] (MonoMac.Foundation.NSObject,MonoMac.ObjCRuntime.Selector)
at (wrapper managed-to-native) MonoMac.ObjCRuntime.Messaging:void_objc_msgSend_intptr_intptr_bool (intptr,intptr,intptr,intptr,bool)
at MonoMac.Foundation.NSObject.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0
at MonoMac.Foundation.NSObject.Finalize () [0x00000] in <filename unknown>:0
Im stuck here.Please help me.

Deploying ASP.NET 5 app to EC2 in a Docker container

I have a t2.micro EC2 instance running Amazon Linux AMI 2015.03.1. I installed docker on it, but then also updated it manually. Finally, I made the docker daemon listen on a port of my choosing so I could publish to it remotely.
On my development machine, I added to my VS2015 install the VS2015 Tools for Docker - August Preview. I added a new ASP.NET 5 Web Application, built it and hit publish. The container makes it to the host, but it never runs because of this exception;
System.TypeLoadException: Could not load type 'Microsoft.Framework.Configuration.IConfigurationRoot' from assembly 'Microsoft.Framework.Configuration.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [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 Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute (System.Reflection.Assembly assembly, System.String[] args, IServiceProvider serviceProvider) [0x00000] in <filename unknown>:0
at Microsoft.Dnx.ApplicationHost.Program.ExecuteMain (Microsoft.Dnx.Runtime.DefaultHost host, System.String applicationName, System.String[] args) [0x00000] in <filename unknown>:0
at Microsoft.Dnx.ApplicationHost.Program.Main (System.String[] args) [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 Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute (System.Reflection.Assembly assembly, System.String[] args, IServiceProvider serviceProvider) [0x00000] in <filename unknown>:0
at Microsoft.Dnx.Host.Bootstrapper.RunAsync (System.Collections.Generic.List`1 args, IRuntimeEnvironment env, System.Runtime.Versioning.FrameworkName targetFramework) [0x00000] in <filename unknown>:0
This was an issue due to multiple projects references different versions of ASP.NET5 - ie; beta7 & beta6.
Ensuring only one stream was referenced in all project.json's resolved this issue.

Error when try to use EntityFramework 7 + SQLite on OSX

I'm try to use EntityFramework 7 + SQLite on a sample App with .Net Core on a Mac OSX environment. I have installed the Mono 4.0.2 and .Net Version Manager, this is my "dnvm list" command result:
1.0.0-beta7-12274 coreclr x64 darwin
1.0.0-beta6 mono linux/darwin default
1.0.0-beta7-12274 mono linux/darwin
* 1.0.0-beta7-12275 mono linux/darwin
When a try to execute some EntityFramework.Command, the follow problem occurs:
System.TypeLoadException: Could not load type 'Microsoft.Framework.Runtime.ILibraryInformation' from assembly 'Microsoft.Framework.Runtime.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
The full stack is:
System.TypeLoadException: Could not load type 'Microsoft.Framework.Runtime.ILibraryInformation' from assembly 'Microsoft.Framework.Runtime.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
at Microsoft.Data.Entity.Commands.Program.Execute (System.String startupProject, System.Func1 invoke) [0x00000] in <filename unknown>:0
at Microsoft.Data.Entity.Commands.Program.AddMigration (System.String name, System.String context, System.String startupProject) [0x00000] in <filename unknown>:0
at Microsoft.Data.Entity.Commands.Program+<>c__DisplayClass10_1.<Main>b__7 () [0x00000] in <filename unknown>:0
at Microsoft.Framework.Runtime.Common.CommandLine.CommandLineApplication.Execute (System.String[] args) [0x00000] in <filename unknown>:0
at Microsoft.Data.Entity.Commands.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [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 Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute (System.Reflection.Assembly assembly, System.String[] args, IServiceProvider serviceProvider) [0x00000] in <filename unknown>:0
at Microsoft.Framework.ApplicationHost.Program.ExecuteMain (Microsoft.Framework.Runtime.DefaultHost host, System.String applicationName, System.String[] args) [0x00000] in <filename unknown>:0
at Microsoft.Framework.ApplicationHost.Program.Main (System.String[] args) [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 Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute (System.Reflection.Assembly assembly, System.String[] args, IServiceProvider serviceProvider) [0x00000] in <filename unknown>:0
at dnx.host.Bootstrapper.RunAsync (System.Collections.Generic.List1 args, IRuntimeEnvironment env, System.Runtime.Versioning.FrameworkName targetFramework) [0x00000] in :0
ILibraryInformation was renamed recently, and the DNX beta7 you're using probably includes this change: make sure to also reference recent beta7 packages in your project.json file.
You can use the wildcard to reference the latest version:
"dependencies": {
"EntityFramework.Sqlite": "7.0.0-*"
}
Because of project renames, nightly builds are currently broken. To use just beta6, you may need to try these steps:
Remove ~/.dnx/packages. Some of these may contain a mix of post- and pre-rename references.
Ensure you are not using the nightly nuget feed (myget.org)
dnvm use 1.0.0-beta6
Make sure you are using "EntityFramework.Commands": "7.0.0-beta6" and "EntityFramework.Sqlite": "7.0.0-beta6" in project.json.
Follow the Workarounds in the Getting Started on OS X guide.

Resources