Hi,
I've encountered another problem using the bindings for the barcode reader
API.
I've managed to create a binding dll and use it correctly inside a simple
"Universal Project" with just one view. So the following code works
correctly (ScanApiHelper and ScanApiDelegate are the bound Objective C
types):
public partial class AppDelegate : UIApplicationDelegate
{
// class-level declarations
ScanApiHelper api;
ScanApiDelegate del;
UIWindow window;
public override bool FinishedLaunching (UIApplication app, NSDictionary
options)
{
// create a new window instance based on the screen size
window = new UIWindow (UIScreen.MainScreen.Bounds);
AppDomain.CurrentDomain.UnhandledException +=
HandleUnhandledException;
try {
api = new ScanApiHelper ();
del = new ScanApiDelegate ();
api.SetDelegate (del);
api.Open ();
....
With this code I'm able to use the barcode reader and receive a notification
whenever a barcode is read.
However I need to include the barcode reader code inside a class library, so
I created a Monotouch Library Project, added the binding dll as a reference
and created a new class that does the barcode reader initialization:
///// SocketBarcodeReaderManager.cs (inside Monotouch Library Project)
public class SocketBarcodeReaderManager
{
ScanApiHelper api;
ScanApiDelegate del;
public SocketBarcodeReaderManager (){ }
public void Open()
{
try
{
api = new ScanApiHelper ();
del = new ScanApiDelegate ();
api.SetDelegate (del);
api.Open ();
}
catch (Exception ex) { Console.WriteLine(ex.Message); }
}
....
///// AppDelegate.cs (inside main project)
// class-level declarations
SocketBarcodeReaderManager sktManager;
public override bool FinishedLaunching (UIApplication app, NSDictionary
options)
{
// create a new window instance based on the screen size
window = new UIWindow (UIScreen.MainScreen.Bounds);
AppDomain.CurrentDomain.UnhandledException += HandleUnhandledException;
try {
sktManager = new SocketBarcodeReaderManager();
sktManager.Open();
.....
The problem is, the app now crashes without raising any exception when I
call the "api.SetDelegate(del)" method inside SocketBarcodeReaderManager.cs.
I took a look at the Organizer window, but I can't figure out what the
problem is from the information that is displayed there:
......
Date/Time: 2012-08-13 11:44:46.740 +0100
OS Version: iPhone OS 5.1.1 (9B206)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_PROTECTION_FAILURE at 0x2fd00ffc
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 TestSktDllBinding 0x0049fc2a
mono_method_signature_checked (loader.c:2210)
1 TestSktDllBinding 0x0049ff54 mono_method_signature
(loader.c:2350)
2 TestSktDllBinding 0x004513d4
mono_jit_runtime_invoke (mini.c:5753)
3 TestSktDllBinding 0x004c1d10 mono_runtime_invoke
(object.c:2758)
4 TestSktDllBinding 0x00502490 monotouch_trampoline
(monotouch-glue.m:808)
5 TestSktDllBinding 0x001a7f24
wrapper_managed_to_native_MonoTouch_ObjCRuntime_Messaging_void_objc_msgSend_IntPtr_intptr_intptr_intptr
(monotouch.dll.7.s:32423)
6 TestSktDllBinding 0x00344aa4
wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr
(mscorlib.dll.7.s:149938)
7 TestSktDllBinding 0x004514e8
mono_jit_runtime_invoke (mini.c:5786)
8 TestSktDllBinding 0x004c1d10 mono_runtime_invoke
(object.c:2758)
......
Once again, if I use the same code directly in the FinishedLaunching method
in the AppDelegate, everything works fine.
Any suggestions?
Thanks
--
View this message in context:
http://monotouch.2284126.n4.nabble.com/Problems-creating-bindings-to-a-barcode-reader-API-tp4656449p4656490.html
Sent from the MonoTouch mailing list archive at Nabble.com.
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch