CorePlot MonoMac bindings crashing

孤街醉人 提交于 2020-01-11 11:47:08

问题


I am trying to use the CorePlot 0.9 binding for monomac, but that seems to be a hard task. The monotouch sample builds and runs without any problems, but I don't need that one.

Since only a CorePlotiOS.dll was present in the binding, I had to build one for osx myself, but first of af all, no bmake.exe was present, so I had to download the monomac source and build it myself first. Then I tried to build the CorePlotOSX.dll but that caused some compilation problems. Looking at the build-script for mono touch I tried with this line instead:

MONO_PATH=$(MONOMAC)/src mono $(MONOMAC)/src/bmac.exe -e -unsafe coreplot.cs -s=enums.cs -x=extras.cs -x=AssemblyInfo.cs  --sourceonly=list --tmpdir=osx -r:System.Drawing -r:MonoMac -lib:$(MONOMAC)/src -baselib:$(MONOMAC)/src/MonoMac.dll .

Anything wrong there?

I have reduced the problem to this:

graph = new CPTPieChart(); 
graph.Title = "Test";

The allocation seems to survive, but whenever I try to access the object, I crash:

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000000bf887fac

VM Regions Near 0xbf887fac:
    Stack                  00000000b038d000-00000000b040e000 [  516K] rw-/rwx SM=COW  
--> Stack                  00000000bc088000-00000000bf888000 [ 56.0M] ---/rwx SM=NUL  
    Stack                  00000000bf888000-00000000c0088000 [ 8192K] rw-/rwx SM=COW  

Application Specific Information:
objc[17645]: garbage collection is OFF

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   com.apple.CoreFoundation        0x97c8aebc __CFStringEncodeByteStream + 12
1   com.apple.Foundation            0x9ac8ed49 -[NSString(NSStringOtherEncodings) getBytes:maxLength:usedLength:encoding:options:range:remainingRange:] + 263
2   com.apple.Foundation            0x9ac8e8ee bytesInEncoding + 213
3   com.apple.Foundation            0x9ac8e814 -[NSString(NSStringOtherEncodings) UTF8String] + 42
4   com.apple.CoreFoundation        0x97ce478c -[__NSCFString UTF8String] + 204
5   ???                             0x00f91208 0 + 16323080
6   ???                             0x030d708c 0 + 51212428
7   ???                             0x030d703c 0 + 51212348
8   ???                             0x016877d4 0 + 23623636

Any ideas? Running Mac OSX 10.7.5 btw.


回答1:


Ok, that was hard. After several days of fighting xcode and monomac, it turned out, that the native CorePlot framework (dynamic lib) was not loaded. I was not aware, that I was supposed to load it myself (I am a monomac newbie, sorry...but isn't it rather ugly it fails silently in that way??)

Two ways to do this: either

Dlfcn.dlopen ("CorePlot.framework/CorePlot", 2); // 2 = load now, 0 = lazy load

or [assembly:MonoMac.RequiredFramework("CorePlot.framework/CorePlot")]



来源:https://stackoverflow.com/questions/14230031/coreplot-monomac-bindings-crashing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!