mkbundle and MEF - mono

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.

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 crashing in MakeBundle.QueueAssembly - null reference exception

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

ASP.NET vNext on Linux Ubuntu 14.04. Unable to load Kestrel

I've installed mono 3.8.0, installed kvm and ran the kp=vm upgrade and
My K runtime version is as follows
Active Version Runtime Location Alias
1.0.0-beta3 mono ~/.k/runtimes default
After running the kpm restore from the folder containing the project.json file
I get an error while running the k kestrel command.
I guess the following error has to do with the libuv installation, which I also have installed - version 1.4.2, or at least I think so. Has anyone come across this error ?
System.InvalidOperationException: Unable to load application or execute command 'Microsoft.AspNet.Hosting'. Available commands: web, kestrel. at Microsoft.Framework.ApplicationHost.Program.ThrowEntryPointNotfoundException (Microsoft.Framework.Runtime.DefaultHost host, System.String applicationName, System.Exception innerException) [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
Turns out that the problem was pretty simple. Although I had the kestrel command defined in the project.json file, I did not include the "Kestrel" dependency in the dependencies section.
Once I added that it worked.
For beta3, you need mono 3.12..

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!

NAnt build issues with Mono

I am trying to build a Mono project using NAnt but I get the error listed below. I have tried altering the environment variable PKG_CONFIG_PATH to include the path leading to the file: mono.pc but that does not seem to work.
Failed to initialize the 'Mono 3.5 Profile' (mono-3.5) target framework.:
NAnt.Core.BuildException: Failed to initialize the 'Mono 3.5 Profile' (mono-3.5) target framework. ---> Unable to locate 'mono' module using pkg-config. Download the Mono development packages from http://www.mono-project.com/downloads/.:
NAnt.Core.BuildException: Unable to locate 'mono' module using pkg-config. Download the Mono development packages from http://www.mono-project.com/downloads/.
at NAnt.Core.Tasks.FailTask.ExecuteTask () [0x00000] in <filename unknown>:0
at NAnt.Core.Task.Execute () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at NAnt.Core.FrameworkInfo.Init () [0x00000] in <filename unknown>:0
at NAnt.Core.FrameworkInfo.Validate () [0x00000] in <filename unknown>:0
at NAnt.Core.ProjectSettingsLoader.ConfigureRuntimeFramework () [0x00000] in <filename unknown>:0
I've recently had the same problem trying to install the TAO Framework on Mac OSX 10.6.5 under Mono 2.8.1 with Nant 0.90 (FYI). Here's how I was led to solve this (guided by this page):
Locate the nant script itself ('/usr/bin/nant' on OSX, try 'which nant')
Open the 'nant' script in an editor (you might need the right permissions).
On a new line and before the 'exec ...' line, add something like:
export
PKG_CONFIG_PATH=/path/to/Mono/Framework/Versions/VERSION/lib/pkgconfig
my Mac OSX version looks like:
export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig:/Library/Frameworks/Mono.framework/Versions/Current/lib/pkgconfig/
(nb. my version actually has 2 pkgconfig paths, separated by a colon ':', '/usr/lib/pkgconfig' is also searched automatically, JFYI).
Also, you should add the exact same 'export' line to one of your .bashrc or .profile files (or the corresponding /etc/bashrc or /etc/profile files to set this globally).
Hope this helps.
Cheers
Rich
For me adding '/Library/Frameworks/Mono.framework/Versions/Current/bin' to the PATH has solved the issue on Mac OS X 10.7.3 with Mono 2.10.9 and NAnt 0.91.