How to create a .app mono bundle for Mac OS - c#

I am trying to create a .app bundle of my mono program to run on Mac OS X, but despite having read virtually all articles and documentation on macpack and bundling mono, none of the methods work.
Using macpack the binaries are bundled successfully in a .app package:
macpack -m:x11 -o:. -r:sqlite3.dll -r:Nini.dll -r:extraIcons.ini -r:APP_DATABASE.db3 -r:APP_Values.db3 -r:./Documents/manual.pdf -r:GemBox.Spreadsheet.dll -r:Mono.Data.SqliteClient.dll -a:APP.exe -n:APP
. When I try to start the program from the package this happens:
FFMACM-2:MacOS dev$ open -a APP
LSOpenURLsWithRole() failed for the application /Users/dev/Workspace/Software/APP.app with error -10810.
I tried using this method but the script fails with the following error:
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Nini, Version=1.1.0.0, Culture=neutral, PublicKeyToken=691faec150a7fa7b' or one of its dependencies.
File name: 'Nini, Version=1.1.0.0, Culture=neutral, PublicKeyToken=691faec150a7fa7b'
at APP.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0
logout
I am fresh out of ideas. The Nini.dll is where it should be. I am using GTK# for the GUI.

Creating a package for MacOS X is now done using MonoMacPackager. You can find details here http://www.mono-project.com/MonoMacPackager.
However, the issue that you're seeing here is that you're missing your dll (The Nini assembly) from your package. It needs to be in your application path (after it has been bundled) to load properly.

Related

Publishing WPF Application with EmguCV and Clickonce

I've been trying to publish a WPF application I've been working on to a specific folder using Microsoft Clickonce. In my application I use the OpenCV wrapper EmguCV. However, when I publish the application and download and install it on a new machine, it gets thrown the following error.
Application: Photo.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.DllNotFoundException
at Emgu.CV.CvInvoke.RedirectError(CvErrorCallback, IntPtr, IntPtr)
at Emgu.CV.CvInvoke..cctor()
Exception Info: System.TypeInitializationException
at Emgu.CV.CvInvoke.cvCreateImageHeader(System.Drawing.Size, Emgu.CV.CvEnum.IplDepth, Int32)
at Emgu.CV.Image`2[[Emgu.CV.Structure.Gray, Emgu.CV, Version=4.6.0.5131, Culture=neutral, PublicKeyToken=7281126722ab4438],[System.Byte, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].AllocateData(Int32, Int32, Int32)
Whats really confusing me though is if I download my bin folder to that same machine and run the application, it works completely fine. Because of this I know the machine is not missing any runtimes, so it would have to be with Clickonce itself. I've verified that I'm targeting x64, and have also checked that all of the EmguCV dll's are being included in the Application Files section of Clickonce. I've also checked EmguCV's documentation about the issue and I've also verified that I have the correct Nuget package with the Emgu.CV.runtime.windows package.

Could not load file or assembly 'Microsoft.AspNetCore.Http.Extensions, Version=3.1.0.0 in windows 10 machine

I am trying to run my Dotnet-Core web Api project in windows 10 machine. But I am facing runtime error. I 'm not allowed to change the Application nuget version too
>fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HMLLR56JLU26", Request id "0HMLLR56JLU26:0000000B": An unhandled exception was thrown by the application.
System.BadImageFormatException: Could not load file or assembly 'Microsoft.AspNetCore.Http.Extensions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Format of the executable (.exe) or library (.dll) is invalid.
File name: 'Microsoft.AspNetCore.Http.Extensions, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
at Microsoft.AspNetCore.StaticFiles.StaticFileContext.get_RequestHeaders
at Microsoft.AspNetCore.StaticFiles.StaticFileContext.ComputeIfMatch()
at Microsoft.AspNetCore.StaticFiles.StaticFileContext.ComprehendRequestHeaders()
at Microsoft.AspNetCore.StaticFiles.StaticFileContext.ServeStaticFile(HttpContext context, RequestDelegate next)
The answer here lies in - BadImageFormatException. One of these
Your app is compiled for one architecture (x64 or x86) but your Web Server pool runs different one
One of the 3rd party DLLs is of incompatible architecture (your case)
One of your DLLs is of incompatible architecture.
DLL is compiled for the wrong platform. e.g. running DLL compiled for .net4.8 in the .netcore (your case)

Running mpi with C# programs on OS X

I tried running an mpi program written in C# on OSX, however, I keep getting the permission denied error.
The steps I took to install mpi:
installed homebrew
using homebrew installed mpich
installed mono (so I can get a .exe file)
created a project in Rider, specified target frameworks to be net50 (latest .net core) and net48 (assume provided by mono)
installed mpi.net nuget package
went into the Debug directory of net48 containing ConsoleApp1.exe
ran the command mpirun -np 4 ./ConsoleApp1.exe with and without sudo
However, I get the following error:
[proxy:0:0#Marins-MacBook-Pro.local] HYDU_create_process (utils/launch/launch.c:74): execvp error on file ./ConsoleApp1.exe (Permission denied)
The error is repeated once for each process.
Using finder I selected the exe file and parent folder in question and gave everyone permissions to read and write (read permissions are granted by default). However, the problem still persists.
What can I try to solve this issue?
EDIT:
I also tried with the following command:
mpiexec -n 4 mono ConsoleApp1.exe
However, I get the error:
Unhandled Exception:
System.DllNotFoundException: msmpi.dll assembly:<unknown assembly> type:<unknown type> member:(null)
at (wrapper managed-to-native) MPI.Unsafe.MPI_Finalized(int&)
at MPI.Environment.get_Finalized () [0x00000] in <fa7716c2d3a447518b7b229d8fa8506f>:0
at MPI.Environment..ctor (System.String[]& args, MPI.Threading threading) [0x00006] in <fa7716c2d3a447518b7b229d8fa8506f>:0
at MPI.Environment..ctor (System.String[]& args) [0x00000] in <fa7716c2d3a447518b7b229d8fa8506f>:0
at ConsoleApp1.Program.Main (System.String[] args) [0x00001] in <4afb3f1ea5bc4367a9a7afd6da6576a3>:0
I'm not sure whether this is the correct way to use mpi on OS X.

Task Scheduler with .dll

net core 2.0 console app on a schedule only problem is i have a .dll file - I have followed resources which say to put the 'Start-in' option to the path of project and this hasn't worked - however when I navigate to the folder with the dll and run dotnet name.dll in cmd it executes the console app fine.
Here is the error i'm getting
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
rsine provided the answer in his question Scheduling multiple .net core console apps.
Example of 'New Action' form
Program/Script dotnet
Add Arguments program.dll arg1
Start In E:\User\ProgramFolder

System.IO.FileNotFoundException: Could not load file or assembly System.Xml.Linq

I have a mono project that runs fine on my computer (running Ubuntu 16.04), but when I upload it on Ubuntu in AWS, it throws this exception:
System.TypeInitializationException: The type initializer for 'Amazon.AWSConfigs' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies.
On the Ubuntu server, I've installed mono using sudo apt-get install mono-runtime. I assume this didn't install the DLL for System.Xml.Linq.
Note the error isn't about the assembly reference, it's about the actual assembly DLL file missing. Using strace mono ParamStoreTest.exe shows that it tries to search for the DLL but can't find it:
open("/usr/lib/System.Xml.Linq.dll", O_RDONLY) = -1 ENOENT (No such file or directory)
After running dpkg -S System.Xml.Linq to find out which package installs it, I ran sudo apt-get install libmono-system-xml-linq4.0-cil on the EC2 machine. This fixed the issue.

Categories

Resources