mkbundle crashing in MakeBundle.QueueAssembly - null reference exception - mono

I have been trying to bundle our ink compiler using mkbundle. Here's how I run it:
mkbundle --static --sdk /Library/Frameworks/Mono.framework/Versions/Current --deps inklecate.exe ink-engine-runtime.dll -o inklecate_mac
...but I get crash with the following stack trace:
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
at MakeBundle.QueueAssembly (System.Collections.Generic.List`1[T] files, System.String codebase) [0x000bc] in <984a17ca6b0b4a0286f5e4481cb18cc8>:0
at MakeBundle.QueueAssembly (System.Collections.Generic.List`1[T] files, System.String codebase) [0x000bc] in <984a17ca6b0b4a0286f5e4481cb18cc8>:0
at MakeBundle.Main (System.String[] args) [0x00d5f] in <984a17ca6b0b4a0286f5e4481cb18cc8>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
at MakeBundle.QueueAssembly (System.Collections.Generic.List`1[T] files, System.String codebase) [0x000bc] in <984a17ca6b0b4a0286f5e4481cb18cc8>:0
at MakeBundle.QueueAssembly (System.Collections.Generic.List`1[T] files, System.String codebase) [0x000bc] in <984a17ca6b0b4a0286f5e4481cb18cc8>:0
at MakeBundle.Main (System.String[] args) [0x00d5f] in <984a17ca6b0b4a0286f5e4481cb18cc8>:0
It used to work fine... perhaps it's broken since I updated mono a little while back? I'm currently on version 5.2.0.224.
(If you want to reproduce on Mac, you should be able to grab the git repo I linked above, and run the build_for_inky.command script.)

Related

Mono Framework Build Error - Mac OSX

When using the Mono framework 5.10.0.16 (regardless of IDE: VS for Mac, JetBrains Rider and MonoDevelop) the same error occurs and I cannot make sense of it:
Microsoft.VisualBasic.Core.targets(73, 5): [MSB3883] Unexpected exception:
Microsoft.VisualBasic.Core.targets(73, 5): [null] System.ComponentModel.Win32Exception (0x80004005): ApplicationName='vbnc.exe', CommandLine=' /noconfig #"/var/folders/sj/sblgn2q93b1084nm213419f80000gn/T/tmp54fb2d36c21545118516981a1817b134.rsp"', CurrentDirectory='', Native error= Cannot find the specified file
at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) [0x002dc] in <f8bb3922e51744d9ace1aa6aedc374ea>:0
at System.Diagnostics.Process.Start () [0x0003a] in <f8bb3922e51744d9ace1aa6aedc374ea>:0
at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
at Microsoft.Build.Utilities.ToolTask.ExecuteTool (System.String pathToTool, System.String responseFileCommands, System.String commandLineCommands) [0x000c9] in <0027e94ddd2948b0b937f5e2d51fcfe1>:0
at Microsoft.CodeAnalysis.BuildTasks.ManagedCompiler.ExecuteTool (System.String pathToTool, System.String responseFileCommands, System.String commandLineCommands) [0x00066] in <896b154c97654cea80889fd96e18abdc>:0
I have tried installing different versions, the error persists, I'm not sure what to make of it but I notice a vnbc.exe
I am using MacOSX version 10.13.4
This issue in mono https://github.com/mono/mono/issues/7756. It's already fixed. We are waiting for new release.

mkbundle and MEF

I have written an app that runs on my target Linux BeagleBone Black with Debian 8 derived OS.
It will run if I install the whole mono-runtime. This is too big for the final targets that I will be running it on.
I would like to use mkbundle to create a static package that has everything embedded.
The problem I am having is that I am using MEF and dependancy injection in this app and when I run the final bundle that mkbundle creates I am getting the error shown below.
I suspect that is because that MEF and / or my app is written to load most of the exports by loading DLL assemblies and they are embedded inside the bundle.
Can anyone shed some light on this?
Here is the error:
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: 'path' cannot be an empty string ("").
Parameter name: path
at Microsoft.Internal.Requires.NotNullOrEmpty (System.String value, System.String parameterName) [0x00022] in <0007e672dd7f4959adc6f8103d9c843f>:0
at System.ComponentModel.Composition.Hosting.DirectoryCatalog..ctor (System.String path, System.String searchPattern) [0x00011] in <0007e672dd7f4959adc6f8103d9c843f>:0
at NonWindowsCommon.MefDI.<DirectoryCatalogContainer>m__1 (System.String path) [0x00022] in <15e2f18d34444e41a666c99ead602eed>:0
at System.Linq.Enumerable+WhereSelectEnumerableIterator`2[TSource,TResult].MoveNext () [0x00064] in <63992662b765477a898ef49cdcc99ee2>:0
at System.Diagnostics.Contracts.Contract.ForAll[T] (System.Collections.Generic.IEnumerable`1[T] collection, System.Predicate`1[T] predicate) [0x00048] in <8f2c484307284b51944a1a13a14c0266>:0
at Microsoft.Internal.Requires.NotNullElements[T] (System.Collections.Generic.IEnumerable`1[T] values, System.String parameterName) [0x00013] in <0007e672dd7f4959adc6f8103d9c843f>:0
at Microsoft.Internal.Requires.NullOrNotNullElements[T] (System.Collections.Generic.IEnumerable`1[T] values, System.String parameterName) [0x00000] in <0007e672dd7f4959adc6f8103d9c843f>:0
at System.ComponentModel.Composition.Hosting.AggregateCatalog..ctor (System.Collections.Generic.IEnumerable`1[T] catalogs) [0x00006] in <0007e672dd7f4959adc6f8103d9c843f>:0
at NonWindowsCommon.MefDI.DirectoryCatalogContainer (System.String basepath) [0x0002c] in <15e2f18d34444e41a666c99ead602eed>:0
at Ignition.CommandLine.Program.Configure () [0x0006b] in <c9925f8b4dd141c2a6ea39dd7842d0d4>:0
at Ignition.CommandLine.Program..ctor () [0x00012] in <c9925f8b4dd141c2a6ea39dd7842d0d4>:0
at Ignition.CommandLine.Program.Main (System.String[] args) [0x00001] in <c9925f8b4dd141c2a6ea39dd7842d0d4>:0
Turns out that the code one of our other devs had written was creating our composition container using the exe path. This exe path is "" for the main EXE when run from inside of an mkbundle created EXE.
This was causing the code that dev had written to use an empty path.
I was able to solve it by simply keeping track of the true EXE path and passing that in the the method used to create the container.

using p4net.api in Mono

Anyone managed to get the Perforce p4api.net work with Linux ?
My projects build correctly on Mono 2.8.4, the dlls (p4bridge.dll and p4api.net.dll are in bin/Debug, but whenever I try to execute it, I get this exception :
Unhandled Exception: System.DllNotFoundException: p4bridge.dll
at (wrapper managed-to-native) Perforce.P4.P4Bridge:ConnectA (string,string,string,string,Perforce.P4.P4CallBacks/LogMessageDelegate)
at Perforce.P4.P4Server..ctor (System.String server, System.String user, System.String pass, System.String ws_client) [0x00000] in <filename unknown>:0
at Perforce.P4.Connection.Connect (Perforce.P4.Options options) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: p4bridge.dll
at (wrapper managed-to-native) Perforce.P4.P4Bridge:ConnectA (string,string,string,string,Perforce.P4.P4CallBacks/LogMessageDelegate)
at Perforce.P4.P4Server..ctor (System.String server, System.String user, System.String pass, System.String ws_client) [0x00000] in <filename unknown>:0
at Perforce.P4.Connection.Connect (Perforce.P4.Options options) [0x00000] in <filename unknown>:0
The API is the latest (2013.3) with MonoDevelop 2.8.4 as mentionned, and all mono RPMs are up to date.
Again, as mentionned, both Perforce DLLs are copied into bin/Debug, the project compiles properly, and it does find the p4api.net.dll (as the exception shows), but not the p4bridge.dll. I'm starting to suspect that p4bridge.dll is not a managed .NET library.
Any ideas ?
--JFG
p4bridge is not a managed library so you would need to build it for each platform that you want to run on.
If you want to use P4NET.API in Mono, you could take a look at the P4Connect source code. That project includes a version of the P4NET.API library which works in OSX under Mono. They have yet to integrate that code back into the main P4NET.API library though.

Can't find System.Data.SQLite in MonoMac project

I'm trying to use a SQLite database in a MonoMac program (with the intent of reusing the database in a MonoTouch app).
I've tried two different ORMs, and both fail with the same issue. Searching around online, I discovered the MONO_LOG_LEVEL=debug flag, and a lot of information, but I can't quite get it working.
Currently, I'm referencing Mono.Data.SQLite, but from what I've found, it seems that that is just a wrapper for a system-specific version.
Here's the error output:
Mono: The request to load the assembly System.Data v2.0.0.0 was remapped to v4.0.0.0
Mono: Assembly Loader probing location: '/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/mono/gac/System.Data/4.0.0.0_b77a5c561934e089/System.Data.dll'.
Mono: Image addref System.Data[0x62ada0] -> /Library/Frameworks/Mono.framework/Versions/2.10.9/lib/mono/gac/System.Data/4.0.0.0_b77a5c561934e089/System.Data.dll[0xbd5600]: 2
Mono: Assembly System.Data[0x62ada0] added to domain SQLTest.exe, ref_count=1
Mono: AOT failed to load AOT module /Library/Frameworks/Mono.framework/Versions/2.10.9/lib/mono/gac/System.Data/4.0.0.0_b77a5c561934e089/System.Data.dll.dylib: dlopen(/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/mono/gac/System.Data/4.0.0.0_b77a5c561934e089/System.Data.dll.dylib, 9): image not found
Mono: Assembly Loader loaded assembly from location: '/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/mono/gac/System.Data/4.0.0.0_b77a5c561934e089/System.Data.dll'.
Mono: Config attempting to parse: '/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/mono/gac/System.Data/4.0.0.0_b77a5c561934e089/System.Data.dll.config'.
Mono: Config attempting to parse: '/Library/Frameworks/Mono.framework/Versions/2.10.9/etc/mono/assemblies/System.Data/System.Data.config'.
Mono: Assembly Ref addref Catnap[0x6213c0] -> System.Data[0x62ada0]: 2
Mono: Assembly Ref addref System.Data[0x62ada0] -> mscorlib[0x1001d90]: 6
Mono: Assembly Loader probing location: '/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/System.Data.SQLite.dll'.
Mono: Assembly Loader probing location: '/Library/Frameworks/Mono.framework/Versions/2.10.9/lib/System.Data.SQLite.exe'.
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Data.SQLite' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Data.SQLite'
at System.AppDomain.Load (System.String assemblyString, System.Security.Policy.Evidence assemblySecurity, Boolean refonly) [0x00000] in :0
at System.AppDomain.Load (System.String assemblyString) [0x00000] in :0
at (wrapper remoting-invoke-with-check) System.AppDomain:Load (string)
at System.Reflection.Assembly.Load (System.String assemblyString) [0x00000] in :0
at Catnap.Database.BaseDbAdapter.ResolveConnectionType (System.String connectionTypeAssemblyName) [0x00000] in :0
at Catnap.Database.Sqlite.BaseSqliteAdapter..ctor (System.String connectionTypeAssemblyName) [0x00000] in :0
at Catnap.Database.Sqlite.SqliteAdapter..ctor () [0x00000] in :0
at Catnap.DbAdapter.get_Sqlite () [0x00000] in :0
at YAData.Connection.Connect () [0x00000] in :0
at SQLTest.MainClass.Main (System.String[] args) [0x00000] in :0
I've tried adding a config file with
<configuration>
<dllmap dll="sqlite3" target="/usr/local/lib/libsqlite3.0.dylib" os="!windows"/>
</configuration>
to the application, and I've tried modifying /Library/Frameworks/Mono.framework/Versions/2.10.9/etc/mono/config, but nothing has worked. It's still looking in the wrong places and not finding SQLite.
Help please?
I still don't know why it was looking for System.Data.SQLite, but I recompiled one of the ORMs myself rather than using the provided dll, and it worked. I'm sure some of the problem was that I was using the MonoTouch dll in a MonoMac project. Recompiling CoolStorage (which uses Mono.Data.Sqlite instead of System.Data.SQLite) resolved it.
If anyone can give me an explanation, I'll switch accepted answers.
On with the code!

mono gtk hello world failing, 'Missing method'

I am trying out mono for the first time. Here are the steps I took to set it up.
Installed Kubuntu 12.04 LTS in VirtualBox
apt-get install mono-complete gtk-sharp2
Then I tried running the hello world applications in this tutorial.
http://www.mono-project.com/Mono_Basics
The command line application ran fine.
I compiled the GTK application with the following command as per the instructions:
gmcs hello.cs -pkg:gtk-sharp-2.0
When I run the application it fails with the following errors:
Missing method System.Type::op_Inequality(Type,Type) in assembly /usr/lib/mono/2.0/mscorlib.dll, referenced in assembly /usr/lib/mono/gac/gtk-sharp/2.12.0.0__35e10195dab3c99f/gtk-sharp.dll
Unhandled Exception: System.MissingMethodException: Method not found: 'System.Type.op_Inequality'.
at Gtk.Window..ctor (System.String title) [0x00000] in <filename unknown>:0
at Hello.Main () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.MissingMethodException: Method not found: 'System.Type.op_Inequality'.
at Gtk.Window..ctor (System.String title) [0x00000] in <filename unknown>:0
at Hello.Main () [0x00000] in <filename unknown>:0
To me it looks like the mono libraries are incompatible with the gtk-sharp libraries.
Does anyone have any suggestions on how I can get this working?
All 12.04 Ubuntu editions have Mono defaulting to 4.0 profile (similar to .NET 4.0). You are compiling your hello.cs using gmcs compiler which is intended to target 2.0 profile (similar to .NET 2.0).
Use dmcs compiler instead of gmcs and the error will go away.