Saturday, July 11, 2009

Deploying iphone application with SQLite database for ad hoc distribution

So...its nice to write something after a while. I have been working on iphone applications lately. I had come across issues and figured the solutions too, but I am still little unsure of what information can be made public and what cannot. (Apple's copy right thing.)

For Ad hoc distribution, I installed my app on my iphone for testing, app was installed fine but the data was blank. The problem was that the database wasn't copied over. After a little fight, found the solution below.

You need to add the sqlite file to you XCode project, in the resources folder. Then in your app delegate code file, in the appDidFinishLaunching method, you need to first check if a writable copy of the sqlite file has already been created - ie: a copy of the sqlite file has been created in the users document folder on the iphone's file system, if yes, you don't do anything, else you would overwrite it with the default xcode sqlite copy.

See below code example to do this. This method is called from the app delegates appDidFinishLaunching method.


// Creates a writable copy of the bundled default database in the application Documents directory.
- (void)createEditableCopyOfDatabaseIfNeeded {
// First, test for existence.
BOOL success;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"bookdb.sql"];
success = [fileManager fileExistsAtPath:writableDBPath];
if (success) return;
// The writable database does not exist, so copy the default to the appropriate location.
NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"bookdb.sql"];
success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&error];
if (!success) {
NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);
}
}

Monday, May 18, 2009

System.Web.Hosting.HostingEnvironmentException: Failed to access IIS metabase

I have seen this error for the first time today. This error comes when you have installed Microsoft .Net Framework 2.0 or later before installing Internet Information Services (IIS). I was able to find a solution via google easily, but thought its nice to put on this blog.

RESOLUTION

Follow the steps given below to fix this error

(1) Go to Start | Control Panel | Add and Remove Programs

(2) Click on the entry titled Microsoft .NET Framework 2.0 and select Change/Remove. The Microsoft .NET Framework 2.0 Setup dialog box opens up.

(3) Select the option titled Repair and the setup automatically performs the required repair work.

(4) You might be prompted to reboot the system after the completion of the process.

(5) Run the affected ASP.NET 2.0 application once again and the application should work fine without any problems.

NOTE : If you have installed Visual Studio 2008 Beta or Visual Web Developer Express Beta or .Net Framework 3.5, you may need to repair the .Net Framework 3.5 (Even though you use ASP.Net 2.X in your IIS). You may also need to go to IIS control panel and re-select the ASP.Net version.





Thursday, February 26, 2009

Error Message When You Run Regsvr32.exe on 64-Bit Windows

While working on the server(Data Center) move recently, i faced one issue while running RegSvr32.exe on a 64-bit machine. The machine we are currently using is a 32-bit machine and the new machine that we are going to use is a 64-bit machine. So, long story short, i was trying to register a dll on 64 bit machine, which i thought will be the same way as 32-bit. Put the dll in C:\Windows\System32 and then run Regsvr32.exe and register the dll. BUT, this didn't work on the 64-bit machine.

I googled and found that 64-bit machine considers SYSTEM32 as a 64-bit dlls folder and SysWOW64 (new folder introduced in the 64-bit machine) considers as 32-bit dll folder. And each of these folder has its own regsvr32.exe. So, if you try using a 64-bit regsvr32.exe, it will give you an error "
Filename.dll is not an executable file and no registration helper is registered for this file type.
".

CAUSE: This is because on a 64-bit machine, the default behaviour is to use a 64-bit regsvr32.exe(Which is in System32).


RESOLUTION: To solve this problem, put your dll in the C:\Windows\SysWow64 fodler. Then got to your command window(This should be the one opened from the SysWow64 folder's cmd.exe), run the regsvr32.exe from the path "C:\Windows\SysWow64\" and it will work.

Wednesday, February 4, 2009

Wooohoo...I'm a blogger now!!!

Hello World!!!

It feels great while saying "Hello" to the "World" in real life, rather than in any of the web application! I was thinking to drive-into the blog world since a while now, and I'm finally here!

This blog is about general talk regarding the Technology I come across, any events, incident or about anything that I want to express my thoughts for.

Hope you'll like it.

That's it for today. Keep watching this place for interesting stuff.