Monotouch/WCF Error on iPhone Hardware - wcf

I created a WCF Client on Monotouch with the Silverlight SLSvcUtil.exe Tool similar to http://docs.xamarin.com/ios/tutorials/Working_with_Web_Services#Consuming_WCF_Services.
On the Simulator everything works fine but when i started it on an iPhone 4S i got the error :
Attempting to JIT compile method '(wrapper delegate-begin-invoke) :begin_invoke_IAsyncResult_this__TimeSpan_AsyncCallback_object (System.TimeSpan,System.AsyncCallback,object)' while running with --aot-only.
Any ideas?

I've called a few wcf services from monotouch without hitting any issues like this- so it can be done.
The jit error within monotouch normally indicates either that something has been removed by the linker, or that some virtual abstract method has been called (at least in my recent experience).
Can you check the linker settings for your real iPhone project? Does the problem go away if you set it to -nolink - see http://docs.xamarin.com/ios/advanced_topics/linker
If that does help, then the next step is to take a look within the wcf generated file - can you find and post some more code about the callback method in this case?

Such issues are rarely linker related, even less if the signature is a wrapper. However you can confirm this easily with Stuart's instructions.
IMO you are likely hitting a case where the AOT compiler could not predict the required code. That can happens when mixing generics and value-types (and you have a TimeSpan in generated signature). This will work on the simulator (where the JIT is used) but not when AOT'ing the application.
The best way to solve such issue is to open a bug report at http://bugzilla.xamarin.com and attach a test case that allow us to replicate the issue.

Related

Adding an SQL extension to a precompiled Lua 5.2 project

I have looked into at least 6 different SQL Lua extensions, and they all seem to have their latest version compatible with up to version 5.1 of Lua. I have had zero success in implementing any of them into my current project which uses Lua 5.2, with the best case scenario ending in either silent program crashes or attempt to call global 'module' (a nil value).
I am not the original project owner, so I am trying not to be forced into changing the source code for it (though more recently, I have even gone down that road now).
And often times, it is unclear if these crashes are related to the way the project itself operates, the way the project implements Lua (as a static library), the way that Lua tries to implement it's extensions, the way the extensions implement their dependencies, a versioning conflict, or some sort of crazy combination of each. It's practically impossible to debug a silent crash in this manner, because the source of evil could literally be anything.
As the answer states in this question, I have even tried supporting the module function (which most lua sql extensions utilize, but was deprecated in 5.2), but the program still crashes or just complains about a seemingly infinite amount of missing dependencies. And after spending hours of tracking down (what would seem to be) all of the dependencies it would complain about, it still crashes.
Changing the project's source code to use the Lua 5.1 source appears to break the functionality of the project, resulting in various compiler errors regarding missing 5.2-related functions. Linking the MySQL C/C++ connector to the project results in rather vague runtime errors, which seem to conflict with the way the project implements Lua 5.2.
Are there ANY sqlite/MySQL extensions out there which actually work with Lua 5.2 on a 32-bit Windows machine? Preferably, "out-of-the-box" precompiled binaries with Lua source/ffi bindings?
OR alternatively, are there any clear instructions on how to get this set up properly, without having to scavenge through separate instructions across the web for each required assembly?

Titanium NSInvalidArgumentException

I'm trying to build a crossplatform (Android-ios) mobile application, using Titanium SDK. I didn't have a chance for a long time to build it for ios, I only used my Windows-android combination, to test it, and it works great on the Android system. But when i try to build it on the mac for the ios, i get this message, and the application shuts down in a second:
The application has crashed with an uncaught exception
'NSInvalidArgumentException'.
Since i can not provide any relevant code, because the exception doesn't show what's the problem with my javascript code, and I certainly didn't write any native, ios specific code, i have no idea, what to do.
From the few posts i have found here is what i have tried:
Restart Titanium Studio
Clean the project
Made sure to close any ResultSet, and DB objects when done with
them (as suggested here: topic)
Test the code on both 3.0.0 and 2.x.x versions
I'm looking forward to any advice, on how you solved this problem, if you had it!
Thanks in advance!
Update:
The problem was the following: I called hasOwnProperty on Titanium UI elements, and on the ios version these elements don't have this function (which is weird, since every javascript objects have it, if i'm not mistaken).
If you have similar problems, i recomend reading this article, besides mr.VVoos answer, it helps a lot in avoiding the problems i had!
I'm developing with Titanim and iOS & Android for a long time. Usually there are many differences between iOS and Android parts of the code.
In most cases this exceptions means that an operation is called that is not available for the called class. (In Java this would mean: Class.method() -> Class has no method called method()).
You can try to run the app in debug mode (on iOS Simulator). There is a big advantage debuggin iOS compared to Android. Usually the iOS simulator stops if there is an exception and it shows the JavaScript code that caused the exception. Unfortunately this doesn't work all the time and it only works on simulator.
If this does not provide any further information you can do the following:
- go to your app.js and set a breakpoint in one of the first lines.
- start app in debug mode.
- move on this breakpoint each time until your app crashes - maybe then you are able to detect the error or provide further information.
One last tip: Check your code if there are any platform-specific parts. (Like Android Intents and something that is not available on iOS).
I know that this can be very ugly but we had to solve many of these nasty issues while migrating from iOS to Android.

Debugging iOS app with gdb on jailbroken iPod touch | Objective-C Symbols

I'm looking to debug an app on a jailbroken iPod Touch 4, iOS (5.1.1) using. The only problem is GDB doesn't appear to have any knowledge of class/selector names for the app.
Attaching and setting address breakpoints work, but it cannot identify symbols when attempting to use objective-c names. For example, break -[Class Selector:] will fail. (I'm aware that + and - represent different class types.)
Also, I do not have the source for this app and will not be able to acquire it.
I'm looking to purely use GDB on the device without xcode or the source.
Has anyone successfully done this before? Thanks in advance for any answers.
Under the assumption that you're trying to debug an app from the store / a release build then your binary will have had the symbols stripped from it by the compiler. Only debug builds retain the symbols: there's no reason for release builds to keep them.
To find out the names you'll need to disassemble the binary manually and figure out what you need from there. This is a lengthy topic, too long to really type up in great detail here (O'Reilly's Hacking & Securing iOS Applications book has a good step by step tutorial).
Bear in mind that under the hood the Objective-C messaging framework is made up of C: if you're not familiar with things like the objc_msgSend series of functions you might find getting to know them better will help you along. Since every method invocation in Objective-C is sent using objc_msgSend you can effectively figure out class and method names by break-pointing every time it's called (or rather, breakpointing and automatically dumping the contents: it will be called so many times that to do it manually would take far too long).
However, this is only going to help you identify the symbol names: as the symbols are stripped from the binary you're still going to have to breakpoint on the addresses themselves.

How to debug C++/CLI MFC app that crashes before InitInstance

I have this monstrous C++ application built using MFC(mainly) and COM. It links to several libraries and does a lot of scientific computing. So, now I want to add some new features to it and as an organizational policy, we are developing everything new using .NET. So, this new UI feature is going to be built using WPF and will be consumed in this existing C++ application.
I know how to use a WPF control in a C++ application, so that's not the problem. The problem is that when I try to turn on CLR on this project, it takes a lot of time (around 10 minutes) in linking stage to perform the linking and produce a mixed mode executable. In the end, it manages to do so and successfully creates the executable. But the problem is that whenever I launch this executable, it crashes. I tried to debug InitInstance but it crashes somewhere before this. I am a little stumped on what to try next.
Does anybody have any idea what might be the cause of this.
The target framework of the mixed mode assembly is 4.0 (as it should be) so THIS is not the problem here.
FYI, ILDasm fails to load this exe as well. It takes a lot of time, gives no error but it doesn't load it either. This gives me the impression that somehow managed image is not created properly.
Not sure if this is necessary, but it doesn't hurt either. New MFC projects have this in the constructor of your CWinApp-derived class:
#ifdef _MANAGED
// If the application is built using Common Language Runtime support (/clr):
// 1) This additional setting is needed for Restart Manager support to work properly.
// 2) In your project, you must add a reference to System.Windows.Forms in order to build.
System::Windows::Forms::Application::SetUnhandledExceptionMode(System::Windows::Forms::UnhandledExceptionMode::ThrowException);
#endif

Rules about including 3rd party libraries in frameworks

I'm currently working on a framework for interfacing with a web service I wrote. To make life easier, I'm considering using a wrapper around CFNetwork, called ASIHTTPRequest.
That's all wonderful. But what happens if the user already added that class to their project? I'm sure the linker would throw up an error. Is there any way to 'constrain' classes to only exist in a specific framework, so the linker will ignore them outside of that framework/library? Alternatively, I can always use plain CFNetwork APIs, but that's just a pain and as we all know, programmers are lazy =P
Thanks for any ideas/suggestions.
No. There is absolutely no way to do this. You won't get a linker error if you do, but you'll get a runtime warning printed by dyld directly to the console on every single launch, and if the version of ASIHTTPRequest that you bundle differs in any meaningful way from the version the application uses, then you could get bad behavior or a crash.
HTTP really isn't that hard. Why would you use CFNetwork? Just use NSURLConnection.