我使用 NSKeyedUnarchiver 的代码现在在使用来自 Git 的最新 monomac 时会引发 TypeLoadException:
System.EntryPointNotFoundException: monomac_IntPtr_objc_msgSend_IntPtr at at (wrapper managed-to-native) MonoMac.ObjCRuntime.Messaging:monomac_IntPtr_objc_msgSend_IntPtr (intptr,intptr,intptr) at MonoMac.Foundation.NSKeyedUnarchiver..ctor (MonoMac.Foundation.NSData data) [0x0002a] in /Users/richard/Development/MonoMacSources/gitsrc/monomac/src/Foundation/NSKeyedUnarchiver.g.cs:93
使用 Xamarin Studio 附带的 monomac.dll 版本可以正常运行相同的代码。
测试用例:
public NSTextFieldCell Cell = new NSTextFieldCell("string");
public override void AwakeFromNib()
{
base.AwakeFromNib();
Console.WriteLine(Cell.StringValue);
using(NSMutableData data = new NSMutableData())
{
using(NSKeyedArchiver archiver = new NSKeyedArchiver(data))
{
this.Cell.EncodeTo(archiver);
archiver.FinishEncoding();
}
using(NSKeyedUnarchiver unarchiver = new NSKeyedUnarchiver(data))
{
var cell = (NSTextFieldCell)Activator.CreateInstance(typeof(NSTextFieldCell), new object[] { unarchiver });
unarchiver.FinishDecoding();
Console.WriteLine(cell.StringValue);
}
}
}
异常被抛出new NSKeyedUnarchiver(data))
。
有人有想法吗?还是解决方法?