[Mono-osx] First Run.

Sean sean at tinfoilhat.ca
Fri Jun 10 02:53:00 EDT 2005


Hi there,

First of all I'm new to both Apple's and C#.
I've been asked to look into porting a C# application from VS.net to  
Mono.  To do that I have to first learn C# and decided to play around  
a bit.  I wrote up a small 'hello world' application and it works  
fine in Windows but it doesn't on OS X.

The program is trivial and I'm using the same compile command on both  
Windows and OS X.
I've installed mono-1.1.7 via the downloadable package.

Source for my test.cs:
using System.Windows.Forms;

class HellowWindowsForms {
         static void Main() {
                 System.Windows.Forms.MessageBox.Show("C# on OS X");
         }
}

My makefile:
test.app: test.exe
         macpack -a:test.exe -o:. -m:1 -n:test

test.exe: test.cs
         mcs test.cs -r:System.Windows.Forms.dll

clean:
         rm -rf test.app test.exe

I tried just running it like I do in windows:
     mono Test.exe

But I get the following error:
sean-codys-powerbook-g4-15:~/Documents/c# sean$ mono test.exe

Unhandled Exception: System.TypeInitializationException: An exception  
was thrown by the type initializer for MessageBoxForm --->  
System.Reflection.TargetInvocationException: Exception has been  
thrown by the target of an invocation. --->  
System.TypeInitializationException: An exception was thrown by the  
type initializer for System.Drawing.GDIPlus --->  
System.DllNotFoundException: /Library/Frameworks/Mono.framework/ 
Versions/1.1.7/lib/libgdiplus.dylib
in (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup  
(ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartu 
pOutput&)
in <0x0011c> System.Drawing.GDIPlus:.cctor ()--- End of inner  
exception stack trace ---

in <0x00000> <unknown method>
in <0x00110> System.Drawing.Image:InitFromStream (System.IO.Stream  
stream)
in <0x0010c> System.Drawing.Image:InitFromStream (System.IO.Stream  
stream)
in (wrapper remoting-invoke-with-check)  
System.Drawing.Image:InitFromStream (System.IO.Stream)
in <0x00164> System.Drawing.Bitmap:.ctor  
(System.Runtime.Serialization.SerializationInfo info,  
StreamingContext context)
in <0x00000> <unknown method>
in (wrapper managed-to-native)  
System.Reflection.MonoCMethod:InternalInvoke (object,object[])
in <0x000c8> System.Reflection.MonoCMethod:Invoke (System.Object obj,  
BindingFlags invokeAttr, System.Reflection.Binder binder,  
System.Object[] parameters, System.Globalization.CultureInfo  
culture)--- End of inner exception stack trace ---

in <0x00168> System.Reflection.MonoCMethod:Invoke (System.Object obj,  
BindingFlags invokeAttr, System.Reflection.Binder binder,  
System.Object[] parameters, System.Globalization.CultureInfo culture)
in <0x00048> System.Reflection.MethodBase:Invoke (System.Object obj,  
System.Object[] parameters)
in <0x00308> System.Runtime.Serialization.ObjectRecord:LoadData  
(System.Runtime.Serialization.ObjectManager manager,  
ISurrogateSelector selector, StreamingContext context)
in <0x00184> System.Runtime.Serialization.ObjectManager:DoFixups ()
in <0x00070>  
System.Runtime.Serialization.Formatters.Binary.ObjectReader:ReadNextObje 
ct (System.IO.BinaryReader reader)
in <0x000fc>  
System.Runtime.Serialization.Formatters.Binary.ObjectReader:ReadObjectGr 
aph (System.IO.BinaryReader reader, Boolean readHeaders,  
System.Object result, System.Runtime.Remoting.Messaging.Header[]  
headers)
in <0x001b8>  
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter:Deseriali 
ze (System.IO.Stream serializationStream,  
System.Runtime.Remoting.Messaging.HeaderHandler handler)
in <0x0002c>  
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter:Deseriali 
ze (System.IO.Stream serializationStream)
in <0x007d8> System.Resources.ResourceReader:ResourceValue (Int32 index)
in <0x00044> System.Resources.ResourceReader 
+ResourceEnumerator:get_Value ()
in <0x000ec> System.Resources.ResourceSet:ReadResources ()
in <0x00074> System.Resources.ResourceSet:GetObject (System.String  
name, Boolean ignoreCase)
in <0x000d4> System.Resources.ResourceManager:GetObject  
(System.String name, System.Globalization.CultureInfo culture)
in <0x00034> System.Resources.ResourceManager:GetObject  
(System.String name)
in <0x00038> System.Windows.Forms.Locale:GetResource (System.String  
name)
in <0x00028> System.Windows.Forms.MessageBox+MessageBoxForm:.cctor  
()--- End of inner exception stack trace ---

in <0x00000> <unknown method>
in <0x00058> System.Windows.Forms.MessageBox:Show (System.String text)
in <0x00054> System.Windows.Forms.MessageBox:Show (System.String text)
in <0x00014> HellowWindowsForms:Main ()

I thought maybe I was missing a parameter or something in either the  
compile or the invocation but I tried the same code and commands on  
my PC and it works just fine and the message box just pops up.

With some searching I found the following link:
http://galactus.ximian.com/pipermail/mono-list/2005-February/026053.html
http://www.mail-archive.com/mono-winforms-list@lists.ximian.com/ 
msg00137.html

I added:
export DYLD_LIBRARY_PATH=/Library/Frameworks/Mono.framework/Versions/ 
1.1.7/lib
to my shell environment and remade the 'binary'.

Then I ran test.app via:
open ./test.app

The following errors occurred:
sean-codys-powerbook-g4-15:~/Documents/c# sean$ open ./test.app
dyld: Symbol not found: __cg_jpeg_resync_to_restart
   Referenced from: /System/Library/Frameworks/ 
ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/ 
Versions/A/ImageIO
   Expected in: /Library/Frameworks/Mono.framework/Versions/1.1.7/ 
lib//libJPEG.dylib

Trace/BPT trap

I look a look in the library path and noticed I do have libjpeg.dylib  
but not libJPEG.dylib.  I thought this was a 'case sensitive' issue  
so I tried making a symlink but 'ln' wouldn't allow me to as it said  
the file already existed (which it only does in lowercase instance).

Any ideas what I can try next?
I apologize for being clueless with not only C# but with OS X as well.

-- 
Sean






More information about the Mono-osx mailing list