I'm a long-time C# developer but new to Mono and, especially, Gtk#. I have developed a small app using C# and Gtk#. I need this app to work on Windows, Linux and Mac so I decided to go for Mono and, so far, it seems to be a cool framework.
What my simple app does is start up an XSP web server based on a local directory and port chosen by the user. Ideally, I would like my app to work without having to install the Mono framework at first, but this is not a must to begin with. I am using the following libraries:
using System;
using Gtk;
using System.Net;
using Mono.WebServer;
using System.Diagnostics;
I am developing on a Mac (Snow Leopard, 10.6.7). My executable works perfectly on my Mac. But I am having problems with Ubuntu and Windows. My app works partly on Ubuntu (11.04) -- it starts up and seems to be working but fails when I try to start the XSP web server, which seems expectable as Mono.Webserver is probably not installed on my Ubuntu machine. On Windows (7, 64-bit), my app crashes immediately when I double-click on it. The crash report tells me that a System.IO.FileNotFoundException error occurred. Probably due to the same missing XSP library?
Anyway, I looked around on the Internet and learned about mkbundle. I have performed the following setting as suggested by various forum threads:
export AS="as -arch i386"
I have navigated to the /bin/Release directory of my project and, then, run the following command:
mkbundle MivandoLocalServer.exe -o MivandoLocalServer --deps
But I am getting the following output, which eventually fails:
Compiling:
as -arch i386 -o temp.o temp.s
cc -g -o MivandoLocalServer -Wall temp.c `pkg-config --cflags --libs mono-2` temp.o
Package mono-2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `mono-2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'mono-2' found
temp.c:2:36: error: mono/metadata/assembly.h: No such file or directory
temp.c:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘assembly_bundle_MivandoLocalServer_exe’
temp.c:7: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
temp.c:18: error: ‘NULL’ undeclared here (not in a function)
temp.c: In function ‘mono_mkbundle_init’:
temp.c:22: warning: implicit declaration of function ‘mono_register_bundled_assemblies’
temp.c:22: error: ‘bundled’ undeclared (first use in this function)
temp.c:22: error: (Each undeclared identifier is reported only once
temp.c:22: error: for each function it appears in.)
temp.c: In function ‘main’:
temp.c:114: warning: implicit declaration of function ‘mono_set_dirs’
[Fail]
I really do not know what to do from here. I have MacPorts installed and I have read that this might cause some problems with regards to the pkg-config directory. Is this true? If yes, what will I have to do make it work?
I hope that somebody will be able to help me. Thanks!
Best regards,
Sebastian
PS. I have also posted this question in the forums at Mono's homepage but without any responses so far.
Update: I suspect MacPorts for interfering with my pkg-config directory setting. When I entered the following commands into my terminal, mkbundle allowed me to compile. But I am still encountering some problems.
export PKG_CONFIG_PATH="/Library/Frameworks/Mono.framework/Versions/Current/lib/pkgconfig/"
export AS="as -arch i386"
export CC="cc -arch i386"
Executing the following mkbundle command results in a Unix-archive of 4.9 MB that includes all the necessary dependencies. When I double-click on this new file on my Mac, a terminal window pops up and starts my app. Sweet! But this does not work in Windows nor in Ubuntu.
mkbundle MivandoLocalServer.exe -o MivandoLocalServerBundle --deps -z
What I would like to receive is a bundled executable that can be run in Windows and Ubuntu. So far I have not come across a solution that lets me do this. I tried to install MonoDevelop on my Windows 7 machine, copy my solution and build it there. But since my app is dependent on the Mono.WebServer2 library, I am not able to build it on Windows. I have not been able to find the Mono.WebServer2.dll to download for Windows anywhere on the Internet.
First of all this situation covers two separate issues which I will address separately:
Architecture - i386 only
Build and Packaging
1. Architecture
First of all, not all Windows and Linux machines run on the i386 architecture, so make sure you are using one that is. They are more likely to be i386, but Linux can easily run on many architectures and Windows has recently ventured into this path as well (they supported it in the past, but it quickly lost support) with the new tablet PC cpu types.
2. Build and Packaging
When targeting any operating system there are bound to be differences in the packaging paths so you should build for each target OS with that target OS. If you want mkbundle to work on Windows the whole toolchain needs to be installed there and Windows requires a special script to get it right, but since mkbundle was made for Unix-like OSs it should work on Linux without special considerations:
Create C# executable with mkbundle on windows
http://linux.die.net/man/1/mkbundle
Related
I am trying to get my dotnet CLI working. Everytime I invoke it, no matter the command it attempts to install .NET Framework 3.5, fails, and quits. Example:
PS C:\> dotnet --version
Installing .NET Framework 3.5...
Deployment Image Servicing and Management tool
Version 10.0.19041.844
Image Version: 10.0.19044.1348
Enabling feature(s)
[===================100.0%====================]
The operation completed successfully.
.NET Framework 3.5 should be installed
No installation media found!
Insert DVD or USB flash drive and run this file once again.
Press any key to continue . . .
I have used the dotnet-core-uninstall tool to remove everything that it can. I have uninstalled Visual Studio 2019 and 2017 and deleted the /.dotnet folder. The dotnet command issue persists with the same exact output, I don't even want 3.5 because that's not what my projects use (is that what the CLI runs on???). I don't know where it is pointing to or how to check and my google-fu powers have been exhausted.
I also do not have access to edit the system environment variables directly and have to use powershell to do so
FIXED
Turns out there was a C:\windows\dotnet.bat file that was taking precedence over the executables that get installed with any sdk. Deleting it fixed my problem.
The problem turned out to be a stray dotnet.bat file situated in a directory that preceded that of the desired dotnet.exe CLI in your $env:PATH variable, C:\windows\dotnet.bat
Removing the batch file fixed the problem (calling dotnet.exe - i.e. with the filename extension - would have bypassed the problem).
The problem was discovered via the following Get-Command call, which lists all command forms / executable paths for the name dotnet, with the effective one listed first:
Get-Command dotnet -All
Currently I'm developing an application for both Windows and MacOS.
Created a template application for MacOS (10.13.4) using Eto.Platform.Mac64 (2.4.1) nuget package. The application is built for Release build. The problem occurs when trying to launch the .app bundle.
Currently tried:
Opening the bundle using: open -a xxx.app. I got an error -54
using: sudo open -a xxx.app. The error is -10810
Giving all permissions for files inside for execution.
Disabling GateKeeper
Trying to launch the executable directly using mono, although the ETO platform checks if it's launched from .app bundle, and fails there
Launching the .app from /usr/local/bin
Launching the .app from ~/Applications/
Building Eto.Forms for MacOS separately.
Everything seems to point to permissions issue, but I can't seem to understand what am I missing.
Since I'm new with MacOS in general (mostly familiar with linux), any suggestions/help is greatly appreciated.
After checking the Console.app for logs I found out that com.apple.quarantine had marked the application as quarantined.
After xattr -d com.apple.quarantine MyApp.Mac.App/Contents/MacOS/MyApp.Mac
Everything works perfectly.
Thank you Curtis for your suggestions.
I am a .NET Windows developer who is completely new to Linux. I recently built a very simple application in MonoDevelop on the Raspbian image, for use on that same image. Everything works fine when I run the project, but when I build it then try to open it outside of the IDE, it tells me it's a DOS/Windows application. How do I build it so that it will run on Raspbian?
Sorry. Can't ad comment to your comment.
I am at beginner level of Linux, but had encountered issue with the paths of some versions. Probably sudo uses different paths than the regular user. Sudo is not just elevating the permissions, but may contain different settings. If you "fix" the paths than the app might work also without the sudo.
I am running one of the latest versions of Monodevelop on Linux Mint which used to work before I formatted my drive and made a fresh install. When I build my project it builds fine, but when I try to run it I get the following message:
Could not launch ASP.NET web server.
The xsp4 web server cannot be found. Please ensure that it is installed.
I have xsp4 and xsp4-base packages installed. I found in a question and answer on askubuntu that I need to switch the Mono runtime to make it able to find xsp4.
When I go to Edit > Preferences > Projects > .NET Runtimes I see the options Mono 3.10.0 (Default) and Mono 3.10.0 (/usr). Unfortunately, when I switch to the /usr one (the one I need and should work) I get the same error as above that the web server cannot be found. And now the weird part: when I look again in the .NET runtimes options I see that is has switched the default back to the original one.
The switching back to another default only happens after I press F5 and try to build the solution (both with release and debug).
Does anyone know how I can fix this?
In case we're running an ASP.NET application on Mono using Monodevelop for the first time, we may receive the below error:
In some cases, the problem is incorrect installation of xsp4 server.
Install it using:
sudo apt-get install mono-xsp4
This solved the above error.
Optional: get it from Ubuntu software center by searching for xsp4
Extra: For Arch (or based like Manjaro...) use yaourt -S xsp.
source
I am writing an application in C# with Visual Studio 2010 and am close to the end with engineering of my application. For testing i use 3 different machines:
Machine A: Workstation-PC (Intel CPU, Win 7 64Bit, .NET 4.0)
Machine B: Private PC (Intel CPU, Win7 64Bit, .NET 4.0)
Machine C: Labor-PC (AMD64, Win7 64Bit, .NET 4.0)
I want a standalone .exe file for the final version. The application works like a charm on Machines A and B no matter if i run the application in the solution folder or copy it to any directory and run it there. It works always (as it should). But Machine C throws an error, directly on application startup and outputs a "...WERInternalMetadata.xml"-file which says "System.IO.FileNotFoundException":
CLR20r3
myapp.exe
1.0.0.0
53318d78
Testreporter
1.0.0.0
53318d78
5d
f
System.IO.FileNotFoundException
But when I start the application in the solution folder(e.g. ...myapp\bin\x64\Debug), where the *.dll files are contained, the application works perfectly without any problems.
Does this mean, that the program searches for its dependecies in the root directory?
I've already checked the references in code. Furthermore if there were any problems with references, the app would not run on Machine B...
I find it curious that Machines A and B run the program without issues no matter where i place the .exe but Machine C only runs my app properly when placed in specific path....
Maybe the processor plays a role there? Any ideas on how to solve this?
BTW:
How can i build a .exe-file that already contains all dependencies and libraries my application needs. A standalone-exe so to say...
Thank you very much
It looks like the EXE is able to find the necessary DLLs in GAC on machines A and B, but is failing to do so in Machine C. Hence, only the particular path is working.
Please check the GAC.
Also, to embed DLLs into EXEs, refer to this SO thread: Embedding DLLs in a compiled executable
I've found a thread with similar topic, leading me to the solution:
System.IO.FileNotFoundException. Where do I find what path is wrong?
I am using Power Packs, too. When i removed the "Microsoft.VisualBasic.PowerPacks.Vs.dll" from the solution directory and started the application, my program failed with the descripted error. Copying back, then starting the application again was successful. So I guess my the target machine (machine C) needs a Power Pack Installation.
So I guess I can solve this problem in 4 ways?:
1.) Leaving the "Microsoft.VisualBasic.PowerPacks.Vs.dll" with the .exe in same folder and then start my application.
2.) Installing the PowerPack http://go.microsoft.com/fwlink/?LinkID=145727&clcid=0x804
3.) Installing the PowerPack.dll manually to the GAC. Or getting them to the GAC with the corresponding tools as described here http://msdn.microsoft.com/en-us/library/yf1d93sz%28v=vs.110%29.aspx
4.) Embed the .dll right into the .exe
Am I right?
Thank you very much for your help!
I had this problem also, with similar entries in Windows->Application logs, including FileNotFoundException. Very disappointed that every app log clue was just a rabbit hole (lack of specific info on WHAT file).
I eventually discovered the error of my wicked ways via Procmon.exe, and scanning through every line marked "NOT FOUND" in the Result column. There was a companion DLL generated as part of the project that I'd forgotten to copy over to the target machine.
If Procmon.exe ever disappears I'll be dead. It has helped to resolve probably 90% of subtle issues encountered since I began using VisualStudio in 1998.
Gave myself a "BoneHead of The Day" award...