Alright, I'm at a complete loss. I've been messing with Gtk# and Mono for the past two hours and have yet to get anywhere.
I've installed Mono as well as GtkSharp using the links available on Mono's website. I have also installed Gtk itself from their website using MSYS2.
The full code of my application is below:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Gtk;
namespace InstallCheck {
public class GtkSharpTest {
public static void Main() {
Application.Init();
Window window = new Window("Hello Mono World");
window.Show();
Application.Run();
}
}
}
In Visual Studio, I've added references to glib-sharp.dll and gtk-sharp.dll. It builds just fine, but when I go to run it using mono InstallCheck.exe, I get this error:
Unhandled Exception:
System.DllNotFoundException: libglib-2.0-0.dll
at (wrapper managed-to-native) GLib.Marshaller.g_utf16_to_utf8(char*,intptr,intptr,intptr,intptr&)
at GLib.Marshaller.StringToPtrGStrdup (System.String str) [0x00034] in <d973ca9f8b494b789fba7fe0ad040b14>:0
at GLib.Global.set_ProgramName (System.String value) [0x00001] in <d973ca9f8b494b789fba7fe0ad040b14>:0
at Gtk.Application.SetPrgname () [0x0000d] in <35293b6aa2744433b0e2f41f34e699d5>:0
at Gtk.Application.Init () [0x00001] in <35293b6aa2744433b0e2f41f34e699d5>:0
at InstallCheck.GtkSharpTest.Run () [0x00001] in <f385106059954ecb8802348d7a6abfe1>:0
at InstallCheck.GtkSharpTest.Main (System.String[] args) [0x00027] in <f385106059954ecb8802348d7a6abfe1>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: libglib-2.0-0.dll
at (wrapper managed-to-native) GLib.Marshaller.g_utf16_to_utf8(char*,intptr,intptr,intptr,intptr&)
at GLib.Marshaller.StringToPtrGStrdup (System.String str) [0x00034] in <d973ca9f8b494b789fba7fe0ad040b14>:0
at GLib.Global.set_ProgramName (System.String value) [0x00001] in <d973ca9f8b494b789fba7fe0ad040b14>:0
at Gtk.Application.SetPrgname () [0x0000d] in <35293b6aa2744433b0e2f41f34e699d5>:0
at Gtk.Application.Init () [0x00001] in <35293b6aa2744433b0e2f41f34e699d5>:0
at InstallCheck.GtkSharpTest.Run () [0x00001] in <f385106059954ecb8802348d7a6abfe1>:0
at InstallCheck.GtkSharpTest.Main (System.String[] args) [0x00027] in <f385106059954ecb8802348d7a6abfe1>:0
I have no idea what this means. I've Google'd and Bing'd it, and things came up, but the solutions they provided did not work. Yes, Mono is in my Path, and yes, GtkSharp is also in my Path. What am I doing wrong? Is this a GTK Error, a Mono Error, or a VS2017 error? How do I fix it? Thanks in advance.
Edit: I have now attempted to DOWNGRADE Gtk, as recommended by this issue, but that still did not work.
you can use the nuget package GtkSharp.Win32 to create a Gtk application in Visual Studio 2017.
https://github.com/jhojen26/GtkSharpTest
Related
On Visual Studio for Mac 7.1, I am trying to build a project that builds fine on Visual Studio 20176 Update 3.
The first error on a project file is:
Target ResolveKeySource:
/Library/Frameworks/Mono.framework/Versions/5.2.0/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets(3103,5): error MSB3322: Unable to get MD5 checksum for the key file "../xxx.pfx". Could not find file "/Users/PATH/xxx.pfx".
Done building target "ResolveKeySource" in project "yyy" -- FAILED.
The pfx actually exists and is readable.
With more logging enabled, it reads:
error MSB4018: The "ResolveKeySource" task failed unexpectedly.
error MSB4018: System.NotSupportedException: Specified method is not supported.
error MSB4018: at System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeInterfaceAsObject (System.Guid clsid, System.Guid riid) [0x00006] in /private/tmp/source-mono-d15-3/bockbuild-d15-3/profiles/mono-mac-xamarin/build-root/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/interopservices/runtimeenvironment.cs:204
error MSB4018: at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
error MSB4018: at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in /private/tmp/source-mono-d15-3/bockbuild-d15-3/profiles/mono-mac-xamarin/build-root/mono-x64/mcs/class/corlib/System.Reflection/MonoMethod.cs:305
I've been playing around with changing the file format for signing, but would like to have one solution that builds easily on Windows and Mac.
Is there a solution with one file format for signing the assemblies?
I just recompiled some old signing-based Xamarin.Android apps w/ the latest Xamarin versions using msbuild/csc and .pfx just do not work (unless there is some magic I am missing).
But converting the .pfx to a .snk to extract the public key worked fine, use the mono version of "StrongName utility for signing assemblies" (sn) on macOS:
sn -p certificate.pfx certificate.snk
It will prompt you for the password, use the resulting .snk file instead. The .snk file will work fine on Windows also.
I've got a websharper project that runs flawlessly on windows. However it only compiles flawlessly on mac but can't be run. The webserver complains that it can find a file (doesn't name it) and reading the stacktrace it seems to be the C# compiler complaining. However being an F# project that's somewhat surprising.
System.SystemException
Error running mcs: Cannot find the specified file
Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): System.
Exception stack trace:
at Mono.CSharp.CSharpCodeCompiler.CompileFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00135] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/System/Microsoft.CSharp/CSharpCodeCompiler.cs:216
at Mono.CSharp.CSharpCodeCompiler.CompileAssemblyFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00011] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/System/Microsoft.CSharp/CSharpCodeCompiler.cs:136
at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00014] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/System/System.CodeDom.Compiler/CodeDomProvider.cs:111
at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath, System.CodeDom.Compiler.CompilerParameters options) [0x002e8] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/System.Web/System.Web.Compilation/AssemblyBuilder.cs:822
at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00000] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/System.Web/System.Web.Compilation/AssemblyBuilder.cs:731
at System.Web.Compilation.BuildManager.GenerateAssembly (System.Web.Compilation.AssemblyBuilder abuilder, System.Web.Compilation.BuildProviderGroup group, System.Web.VirtualPath vp, Boolean debug) [0x00264] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:826
at System.Web.Compilation.BuildManager.BuildInner (System.Web.VirtualPath vp, Boolean debug) [0x0011c] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:451
at System.Web.Compilation.BuildManager.Build (System.Web.VirtualPath vp) [0x00056] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:396
at System.Web.Compilation.BuildManager.GetCompiledType (System.Web.VirtualPath virtualPath) [0x00040] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:989
at System.Web.Compilation.BuildManager.GetCompiledType (System.String virtualPath) [0x00000] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/System.Web/System.Web.Compilation/BuildManager.cs:972
at System.Web.HttpApplicationFactory.InitType (System.Web.HttpContext context) [0x0016b] in /private/tmp/source-mono-mac-4.0.0-branch-c5sr4/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.4/mcs/class/System.Web/System.Web/HttpApplicationFactory.cs:417
ANy suggestions to what could be the root of this problem?
Seems like a mono installation issue. A similar exception is happening in this ticket: https://forums.xamarin.com/discussion/50713/error-running-mcs-cannot-find-the-specified-file
Upgrading to mono 4.2 alpha resolves the issue. I do however think it can be solved with 4.0 as well since I have had the same web site running on a different Mac without installing 4.2
I'm trying to have Tasks working under Visual Studio 2012 with MonoTouch. I'm using ALPHA channel and have the latest releases installed.
There are 3 projects in solution:
1. PCL (158 target platforms) with async methods
2. Touch
3. Android
This code compiles, could be deployed and executed. But when I make calls from iPhone client:
var asyncResult = await MyClass.DoStuff();
Console.WriteLine("doing stuff completed: " + asyncResult);
I get the following result:
System.PlatformNotSupportedException: This platform is not supported
at await part of code. When I write it with Task.ContinueWith - same result.
What is interesting is doesn't work only under Visual Studio + MonoTouch. All other configurations launches this code correctly (WIN+VS+Android, WIN+VS+Android, MAC+XS+iOS, MAC+XS+Android)
Versions of SDK are synchronized with the latest ALPHA release.
Exception details:
Unhandled Exception:
System.PlatformNotSupportedException: This platform is not supported.
2013-07-25 11:45:32.384 iPhone[1817:907] Unhandled managed exception: This platform is not supported. (System.PlatformNotSupportedException)
at System.ExecutionContextLightup.Run (System.ExecutionContextLightup executionContext, System.Action`1 callback, System.Object state) [0x00000] in <filename unknown>:0
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+MoveNextRunner.Run () [0x00000] in <filename unknown>:0
at Microsoft.Runtime.CompilerServices.TaskAwaiter+<>c__DisplayClassa.<OnCompletedInternal>b__1 (System.Object state) [0x00000] in <filename unknown>:0
at MonoTouch.UIKit.UIKitSynchronizationContext+<Post>c__AnonStorey52.<>m__4E () [0x00000] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIKitSynchronizationContext.cs:24
at MonoTouch.Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Developer/MonoTouch/Source/monotouch/src/shared/Foundation/NSAction.cs:87
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at
MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
at iPhone.Application.Main (System.String[] args) [0x00001] in c:\Sources\Local\PCL_XN\iPhone\Main.cs:17
The program 'Mono' has exited with code 0 (0x0).
The program '[6760] iPhone.vshost.exe: Managed (v4.0.30319)' has exited with code -1 (0xffffffff).
A bit of a late reply, but in case anyone is still running into this, it looks like one workaround is to add --nolinkaway --linkskip=mscorlib under "Project Options -> iOS Build -> Additional mtouch arguments" for the main application project.
Without this, the linker removes something from mscorlib that the Microsoft.Bcl package requires for its compatibility checks.
Bug filed here: https://bugzilla.xamarin.com/show_bug.cgi?id=15290
I am new to mono/linux and I've tried to host my existing asp.net mvc3 website on ubuntu/apache2 using mod_mono. Everything goes ok except the calls to a ServiceStack service which seem to fail when deserializing the response from the service (the service is located on the same machine hosted in a different proc). I have looked at the mono gac and the assembly is there (correct version/key). Moreover if I run the website from monodevelop/xsp everything works just fine. Any idea as to why is the type load failing is appreciated.
Could not load type 'System.Runtime.Serialization.Json.DataContractJsonSerializer' from assembly 'System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
Stack Trace:
System.TypeLoadException: Could not load type 'System.Runtime.Serialization.Json.DataContractJsonSerializer' from assembly 'System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
at ServiceStack.ServiceClient.Web.JsonServiceClient.DeserializeFromStream[List`1] (System.IO.Stream stream) [0x00000] in :0
at ServiceStack.ServiceClient.Web.ServiceClientBase.HandleResponse[List`1] (System.Net.WebResponse webResponse) [0x00000] in :0
at ServiceStack.ServiceClient.Web.ServiceClientBase.Send[List`1] (System.String httpMethod, System.String relativeOrAbsoluteUrl, System.Object request) [0x00000] in :0
I am using:
Mono Runtime Version: 2.10.8.1 (Debian 2.10.8.1-5ubuntu1);
ASP.NET Version: 4.0.30319.1
ServiceStack 3.9.32
I was having the same issue. It's happening because the 3.5 version of System.ServiceModel.Web can't be found at runtime by the ServiceStack libraries. I copied the 3.5 version out of the mono "gac" into my applications bin directory and everything started working correctly. The paths may be different on your system/deployment but here is what I used:
cp /usr/lib/mono/gac/System.ServiceModel.Web/3.5.0.0__31bf3856ad364e35/System.ServiceModel.Web.dll /var/www/path/to/web/app/bin/
I am using mono and monobjc to develop an application to run on Mac OS X 10.6. I am adding some files to a zip file using ICSharpCode.SharpZip. The code is as -
var ms = new MemoryStream();
var zipStream = new ZipOutputStream(ms);
zipStream.PutNextEntry(new ZipEntry(Path.GetFileName(file))
{DateTime = File.GetCreationTime(file),
Size = new FileInfo(file).Length});
Sometimes, not always, The PutNewEntry code throws the following exception -
System.NotSupportedException: CodePage 437 not supported
at System.Text.Encoding.GetEncoding (Int32 codepage) [0x00000] in :0
at ICSharpCode.SharpZipLib.Zip.ZipConstants.ConvertToArray (System.String str) [0x00000] in :0
at ICSharpCode.SharpZipLib.Zip.ZipConstants.ConvertToArray (Int32 flags, System.String str) [0x00000] in :0
at ICSharpCode.SharpZipLib.Zip.ZipOutputStream.PutNextEntry (ICSharpCode.SharpZipLib.Zip.ZipEntry entry) [0x00000] in :0
at (wrapper remoting-invoke-with-check) ICSharpCode.SharpZipLib.Zip.ZipOutputStream:PutNextEntry (ICSharpCode.SharpZipLib.Zip.ZipEntry)
I have the following two questions -
What is the causing the above exception.
It looks like ICSharp may not be the best option. What are the better alternatives?.
I fixed this by creating a tar.gzip instead of using zip. I used ICSharp itself to create the tar file. Mac does not seem to like zip. It could also be because I was using the ICSharp in Mono framework on Mac side and using ICSharp(download from the web) on the windows side. But using tar.gzip resolved this issue.