Tuesday, October 15, 2013

AccessViolationException: Attempted to read or write protected memory - COM libraries

Hello,

In one of my project I have a .NET library that is registered to COM in order to be used from a C++ library.
Due to some error, I had to change the interface of an type; I added a new property ID and I set the type of this ID property to be int.
Once testing was done, I deployed the library in production and I started to see the following error:
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. T
his is often an indication that other memory is corrupt.
   at System.String.wstrcpy(Char* dmem, Char* smem, Int32 charCount)
   at System.String.CtorCharPtrStartLength(Char* ptr, Int32 startIndex, Int32 length)
   at System.StubHelpers.BSTRMarshaler.ConvertToManaged(IntPtr bstr)
...

The source of this error was pretty obvious (since the modification I stated earlier was the only one).
I remembered that the type in which I've added the new property ID is mapped to an Entity Framework type (using AutoMapper) and in this entity the ID was of type decimal. After changing the type from int to decimal, the AccessViolationException was gone...

:|

Sunday, October 13, 2013

Programming languages guide (on Apple AppStore)

My second app was approved on Apple AppStore.
You can find it here.

For support and questions, please comment here!

Friday, September 13, 2013

Technical Dictionary En-Ro App (on Apple AppStore)

Hello,

One of my apps was just approved and you can find it here.

For any questions or issues, please comment here!

Thanks!

Tuesday, September 3, 2013

Create/distribute iOS apps (Cordova/PhoneGap)

Hello,

A while ago I've started creating some mobile apps. Since native development (Java/Objective-C) can take some time, I decided to learn an HTML5 mobile framework. One of the most popular (and free/OSS) frameworks is Apache Cordova. You can learn a lot about Cordova on the web...

Since I've wanted to publish some apps, I've also had to became an Apple Developer, buying an Apple Developer ID/Subscription for iOS apps. After that I was able to connect to Member Center and iTunes Connect to configure my account.

Back to the technical part... Once I finished testing the app on the simulators, I had to create an archive of distribution. The first problem I encountered was CopyPNG error. Since I've created the images on Windows, the build process was unable to copy the png images. In order to fix this I had to open the png images in the Preview app and Export them to png and override the images.
After all images errors were fixed, I got another error during linking because libCordova.a was not found (this is actually a bug in the PhoneGap project template). The solution here was to properly set the path to libCordova.a:
- Go to project settings and Build Tab. Search for "Other Linker Flags"
- Double click on the linker flags for Release and Change ${TARGET_BUILD_DIR}/libCordova.a to ${BUILT_PRODUCTS_DIR}/libCordova.a.
Do a clean... build... and an Archive.

Now I am able to test the app on the device and publish it!

Happy coding!

P.S. I also had some problems when I've entered my banking account information... In Romania it's enough to have only the IBAN + name but iTunesConnect wanted the bank account number (which I thought it's the same as the IBAN). After some trials and errors (and a lot of google searching) I came with nothing - the iTunes Connect kept saying that the bank account number is 16 characters long and it's verified against the IBAN; I tried various configurations and none worked... Around 2 AM I decided to go to sleep and go to the bank next day and ask them about my bank account number. But in my way to the bed, I thought that if I remove the first 8 characters (which identifies the country and the bank) I'd get something that something that must identify me. The next day I tried my last idea and it worked. So it looks like the bank account number are the last 16 characters in the IBAN.(at least this works in Romania)