Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将Brother PJ-673 SDK(Objective-C)绑定到MonotTouch_Objective C_Xamarin.ios - Fatal编程技术网

将Brother PJ-673 SDK(Objective-C)绑定到MonotTouch

将Brother PJ-673 SDK(Objective-C)绑定到MonotTouch,objective-c,xamarin.ios,Objective C,Xamarin.ios,我正在为Brother PJ-673便携式打印机创建单触式装订。这将在Xamarin.iOS iPad/iPhone应用程序中使用。Brother提供了Objective-C中的SDK,可在 首先,我使用了Xamarin MonoTouch Binding Objective-C指南并创建了一个绑定项目,该项目似乎运行良好。下面是我的ApiDefinition.cs文件(将Objective Sharpie用于该文件的初稿,然后手动更改) MonoTouch绑定项目编译成功,因此接下来我创建了一

我正在为Brother PJ-673便携式打印机创建单触式装订。这将在Xamarin.iOS iPad/iPhone应用程序中使用。Brother提供了Objective-C中的SDK,可在

首先,我使用了Xamarin MonoTouch Binding Objective-C指南并创建了一个绑定项目,该项目似乎运行良好。下面是我的ApiDefinition.cs文件(将Objective Sharpie用于该文件的初稿,然后手动更改)

MonoTouch绑定项目编译成功,因此接下来我创建了一个小型测试应用程序。下面的代码是如何创建相关兄弟类型的本机实例:

partial void PrintTouchDown (NSObject sender)
        {       
            // Initialize printer settings
            BrotherPrintTouchPrintInfo printInfo = new BrotherPrintTouchPrintInfo();

            printInfo.PaperName = "A4_CutSheet";
            printInfo.PrintMode = (int)PrintMode.PRINT_FIT;
            printInfo.Density = 5;
            printInfo.Orientation = (int)Orientation.ORI_PORTRATE;
            printInfo.Halftone = (int)Halftone.HALFTONE_ERRDIF;
            printInfo.HorizontalAlign = (int)HorizontalAlign.ALIGN_CENTER;
            printInfo.VerticalAlign = (int)VerticalAlign.ALIGN_MIDDLE;
            printInfo.PaperAlign = (int)PaperAlign.PAPERALIGN_LEFT;
            printInfo.ExtFlag |= 0;

            // Initialize PJ-673 printer
            BrotherPrintTouchPrinter printer = new BrotherPrintTouchPrinter("Brother PJ-673");
            printer.SetIPAddress("10.20.2.104");
            printer.SetPrintInfo(printInfo);

            //printer.PrintImage(selectedImage.CGImage, 1, 1000);
        }
在调用printer.SetPrinterInfo(printInfo)之前,一切正常。这就是应用程序崩溃的地方,毫无例外。应用程序输出为:

mono-rt: Stacktrace:

mono-rt:   at <unknown> <0xffffffff>
mono-rt:   at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging.int_objc_msgSend_IntPtr (intptr,intptr,intptr) <IL 0x00027, 0xffffffff>
mono-rt:   at BrotherTouchPrinterBinding.BrotherPrintTouchPrinter.SetPrintInfo (BrotherTouchPrinterBinding.BrotherPrintTouchPrintInfo) <IL 0x0002f, 0x000df>
mono-rt:   at BrotherTouchPrinter.iOS.BrotherTouchPrinter_iOSViewController.PrintTouchDown (MonoTouch.Foundation.NSObject) [0x00069] in /Users/claudiu/Projects/BrotherTouchPrinterBinding/BrotherTouchPrinter.iOS/BrotherTouchPrinter.iOSViewController.cs:82
mono-rt:   at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object (object,intptr,intptr,intptr) <IL 0x00052, 0xffffffff>
mono-rt:   at <unknown> <0xffffffff>
mono-rt:   at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <IL 0x0009f, 0xffffffff>
mono-rt:   at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
mono-rt:   at BrotherTouchPrinter.iOS.Application.Main (string[]) [0x00008] in /Users/claudiu/Projects/BrotherTouchPrinterBinding/BrotherTouchPrinter.iOS/Main.cs:16
mono-rt:   at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff
mono-rt: 
Native stacktrace:

mono-rt: 
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================
mono-rt:Stacktrace:
mono-rt:at
mono rt:at(包装器管理为本机)MonoTouch.ObjCRuntime.Messaging.int_objc_msgSend_IntPtr(IntPtr,IntPtr,IntPtr)
mono rt:位于BrotherTouchPrinterBinding.BrotherPrintTouchPrinter.SetPrintInfo(BrotherTouchPrinterBinding.BrotherPrintTouchPrintInfo)
Muno RT:在BooTouthPr.PrTr.IO.BothTouthPrPiTrnIOVIEWSCORDER .PrimTutouChutWON(MangouCuff.Fask.NSObjult[0x000 069])中/用户/ Coudiu/Studio / BooTouTousPrPultBuff/BooTouTouChink。iOSVIEW控制器。CS:82
mono rt:at(包装器运行时调用)。运行时调用此对象(对象、intptr、intptr、intptr)
mono-rt:at
mono rt:at(包装器管理为本机)MonoTouch.UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
mono-rt:at MonoTouch.UIKit.UIApplication.Main(string[],string,string)[0x0004c]in/Developer/MonoTouch/Source/MonoTouch/src/UIKit/UIApplication.cs:38
mono rt:BrotherTouchPrinter.iOS.Application.Main(string[])[0x00008]在/Users/claudiu/Projects/BrotherTouchPrinterBinding/BrotherTouchPrinter.iOS/Main.cs:16中

mono rt:at(包装器运行时调用)。运行时调用无效对象(对象,intptr,intptr,intptr)您提供的堆栈跟踪显示:

mono rt:在BrotherTouchPrinterBinding.BrotherPrintTouchPrinter.PrintImage (MonoTouch.CoreGraphics.CGImage,int,int)

即:

  • 在调用
    printer.SetPrinterInfo(printInfo)
    之后,它似乎不会在那里崩溃

  • 源代码中有一行注释

  • 您确定源代码(以上)与堆栈跟踪匹配吗

    或者,您的意思是崩溃发生在之后(打印时),但仅在调用
    printer.SetPrinterInfo(printInfo)
    时发生


    注意:您可以编辑您的问题以添加/更新信息

    好的,我已经更新了stacktrace。没错stacktrace是为
    PrintImage
    调用准备的。我尝试了
    SetPrinterInfo
    PrintImage
    两种方法只是为了检查,结果都是一样的。你有没有找到答案?我甚至无法通过第一行。我得到以下错误。无法创建类型为“bpsdkBinding.BRPtouchPrintInfo”的本机实例:尚未加载本机类。通过将ObjCRuntime.Class.ThrowOnInitFailure设置为false,可以忽略此条件。是否有人在iOS、Xamarin和Brother print SDK之间有完全工作的链接?我已经编译并运行了它,但它实际上没有打印任何东西(我也找不到任何错误消息)。(此解决方案中的android版本确实有效。)我没有捕获PrintImage函数返回的int,这是错误消息。我已经用iOS和Android的工作代码更新了我的github项目,如果有人发现了这条评论,并且想要一个Xamarin brother打印机的示例,它可以打印。
    mono-rt: Stacktrace:
    
    mono-rt:   at <unknown> <0xffffffff>
    mono-rt:   at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging.int_objc_msgSend_IntPtr (intptr,intptr,intptr) <IL 0x00027, 0xffffffff>
    mono-rt:   at BrotherTouchPrinterBinding.BrotherPrintTouchPrinter.SetPrintInfo (BrotherTouchPrinterBinding.BrotherPrintTouchPrintInfo) <IL 0x0002f, 0x000df>
    mono-rt:   at BrotherTouchPrinter.iOS.BrotherTouchPrinter_iOSViewController.PrintTouchDown (MonoTouch.Foundation.NSObject) [0x00069] in /Users/claudiu/Projects/BrotherTouchPrinterBinding/BrotherTouchPrinter.iOS/BrotherTouchPrinter.iOSViewController.cs:82
    mono-rt:   at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object (object,intptr,intptr,intptr) <IL 0x00052, 0xffffffff>
    mono-rt:   at <unknown> <0xffffffff>
    mono-rt:   at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <IL 0x0009f, 0xffffffff>
    mono-rt:   at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
    mono-rt:   at BrotherTouchPrinter.iOS.Application.Main (string[]) [0x00008] in /Users/claudiu/Projects/BrotherTouchPrinterBinding/BrotherTouchPrinter.iOS/Main.cs:16
    mono-rt:   at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff
    mono-rt: 
    Native stacktrace:
    
    mono-rt: 
    =================================================================
    Got a SIGSEGV while executing native code. This usually indicates
    a fatal error in the mono runtime or one of the native libraries 
    used by your application.
    =================================================================