Unlikely Teacher

1. Share Everything* [Programming Gotchas, Technology News, Insights on Living and Everything in Between]

System.InvalidProgramException: Invalid IL code

September 3rd, 2010 · Dotnet

I created a program in VB Express, tested it and added the application to our daily ANT build using Mono. I then made some modifications and re-compiled with mono. The compile process went well and the program was able to start properly. But when it reached a certain part of the code, I got the error: “System.InvalidProgramException: Invalid IL code“.

I searched all over the web about this problem but was unable to find the root cause of the problem. I then decided to try out re-compiling in VS Express and was presented with lots of compile errors. That’s when I realized that mono’s compiler (specifically vbnc) is not as good as it’s supposed to be (yet). And that you should still try to compile with VS every now and then just to make sure everything’s working.

Lesson of the story: If you get this error, try compiling with VS to see if there are other problems.

→ No CommentsTags: ··

Apple Push Notification: Failed to register with error: Error Domain=NSCocoaErrorDomain

April 5th, 2010 · Objective-C

I’m currently working on getting Push Notifications to work in my test application using Urban Airship’s service and got this message:

Failed to register with error: Error Domain=NSCocoaErrorDomain Code=3000 UserInfo=0x117520 "no valid 'aps-environment' entitlement string found for application"

I searched the web and most of the blogs/tutorials I found mentioned that I needed to create a provisioning profile in my iPhone developer account which is configured for push notifications.

I was pretty confident that my account was setup properly because I was already able to send push notifications before using an app id that I created so I assumed the problem was with my development setup.

Below are the steps I followed to make push notifications working again:

1. Check whether the profile you’re using for the application is the one configured with push

Often times developers will have multiple provisioning profiles to test and develop on devices. In my case, I had a generic/wildcard profile (BLAHBLAHXX.*) for deploying on the device and another profile for an actual app configured for Push notifications (BLAHBLAHXX.com.companyname.appname).

I was using the generic profile when I checked so I had to switch that back to the profile configured for push. To edit your setting choose Project > Edit Project Settings > Code Signing and then choose the appropriate profile.

2. In case step 1 did not fix your problem (like in my situation), delete all the apps in your device which use the provisioning profile for push notification and perform a soft reset.

3. In Xcode, try to clean all targets. Reboot your machine (probably not necessary but it does wonders most of the time). Then re-build and deploy.

I was back in business with APNS after following those three steps.

HTH.

→ 1 CommentTags: ··

Fatal error: Call to undefined function wp_dashboard_setup()

March 24th, 2010 · PHP

I got this error in WordPress this morning when trying to logon to the Admin pages:

Fatal error: Call to undefined function wp_dashboard_setup() in /home/username/public_html/wp-admin/index.php on line 15

I didn’t make any changes or upgrades to the site and the weird part is that all of a sudden, two of our WordPress installations were displaying this error.

UPDATE: March 24, 10:12 PM GMT+8 It looks like the problem is related to A2 Hosting changing the default PHP version (see Neil’s post in the comments section).

I did some Googling and found a workaround.

The solution is to change this line in wp-admin/index.php:

require_once(ABSPATH . 'wp-admin/includes/dashboard.php');

to this line:

require_once('./includes/dashboard.php');

I’m still trying to investigate the cause of the problem but in the meantime, hope this quick fix solves your problem.

Thanks to Florent for sharing his solution. And thanks also to Neil for providing the reason for the error and a better approach to handling the problem for those who are with A2 Hosting.

→ 5 CommentsTags: ·

Unable to read a jre library while constructing the blacklist

December 30th, 2009 · Java, Mac OS X

Yesterday I started playing around with Google App Engine and Java. Today, when I tried upgrading the JDK/VM that Google App Engine is using from Eclipse Galileo to Java 6 in Mac OS X, I got the error below:

com.google.appengine.tools.development.agent.impl.BlackList initBlackList
SEVERE: Unable to read a jre library while constructing the blacklist. Security restrictions may not be entirely emulated. /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/plugin.jar
The server is running at http://localhost:8888/

Fortunately, after a bit of searching I found a quick fix.

cd /System/Library/Frameworks/JavaVM.framework/Resources/Deploy.bundle/Contents/Home/lib/

sudo ln -s plugin.jar plugin2.jar

Details taken from: http://groups.google.com/group/google-appe

→ 3 CommentsTags: ··

Eclipse 3.5 Galileo and SVN (Subversive)

October 1st, 2009 · Java, Tools

With Subversive being an official Eclipse project (2007) and the recent Eclipse 3.5 Galileo release (2009), you may be wondering why Eclipse still does not have SVN support built-in.

But don’t fuss, because it’s not that hard to configure SVN support (using Subversive) with a few simple steps. This document aims to guide you with the install process.

The first time you try to run Eclipse Galileo and click any of the update sites, you’ll probably receive the “Unable to read repository at …” error like what is shown below:

Update Error

To fix this problem, simply select “Galileo” (or any other update site you wish to use) from the “Available Software Sites” link (Help>Install New Software) and click the “Test Connection” option on the right.

Test Connection

Click “OK” when done and select “Galileo” from the “Available Software” dropdown.

Available Software

From the Galileo Update site, choose “Collaboration > Subversive SVN Team Provider”.

Collaboration Subversive

Click Finish/OK when done. Due to licensing restrictions, the connectors need to be installed using another update site.

To do this, simply “Add” the “Subversive SVN Connectors” Update Site: http://community.polarion.com/projects/subversive/download/eclipse/2.0/galileo-site/

Add Subversive Connectors Update Site

Select the Subversion Connectors you need (select all if you’re not sure which ones) and Install.

Select Subversive Connectors

After the installation process, you will be  asked for restart of a Eclipse for the changes to take effect.

To see the available options for SVN, open the “SVN Repository Exploring” perspective.

SVN Repository Exploring Perspective

Hope this helps. Comments and feedback are much appreciated.

Thanks.

→ 2 CommentsTags: ···

Extra Space (20px) in iPhone OS 2.2.1 Nav Bar

July 1st, 2009 · Objective-C

I currently have an iPhone application which has 4 tabs, when I click any of those tabs, the application should show a new view with a Nav Bar which then contains a table view.

My problem: there was blank space (about 20 pixels) showing between the status bar and the Nav Bar. I tried looking in the Nibs about setting this value but without luck.

What’s even weirder is the fact that this problem does not occur when running against the OS 3.0 simulator.

Fortunately, after days of searching, I found the workaround for OS 2.2.1 and below.

    CGRect frame = navController.view.frame;
    frame.origin.y = 0.0;
    navController.view.frame = frame;

Answer taken from iphonedevsdk.com.

Hope this helps!

→ No CommentsTags: ·

Show Desktop Command on Mac OS X

May 21st, 2009 · Mac OS X, Tools

I’m relatively new to Mac OS X and have been struggling to find out how to quickly “Show the Desktop” to see all the icons I have in there.

I have been used to clicking that little “Show Desktop” icon on the bottom left of the screen in Windows and was looking for an equivalent on my Mac.

Fortunately, there is! But it’s not an icon that you would click but some keyboard shortcuts you need to type. For me pressing fn F10 did the trick.

You can find more Expose tips on this page.

→ 5 CommentsTags: ··

PHP writeUTF implementation

May 12th, 2009 · Java, PHP

We currently have an application in Groovy/Grails/Java that we’re slowly porting to PHP (for more affordable hosting costs).

We encountered a problem when we needed to convert one of our routines for writing out a binary file. We were using Java’s DataOutputStream.writeUTF(String) method and had a hard time trying to write binary data in PHP.

After much research on the web, we found a method in PHP called pack(). Below is our PHP implementation of Java’s DOS.writeUTF(String).

	public static function writeUTF($string) {
		$utfString = utf8_encode($string);
		$length = strlen($utfString);
		print(pack("n", $length));
		print($utfString);
		flush();
	}

We don’t claim this to be the exact equivalent of the method, but it gets the job done and the receiving end of the file was able to parse the binary file properly with the new PHP implementation with no modifications to the client code.

Please checkout the pack() documentation for more details.

→ No CommentsTags: ·

vi Page Up/Page down for Mac OS X

May 12th, 2009 · Mac OS X, Tools

In case you’re wondering how to move up or down in “vi” from Mac OS X terminal:

Then CTRL-B and CTRL-F should do the trick.

Got this from the Mac forums at macworld.com.

→ 1 CommentTags: ····

Windows 7 RC and Ubuntu 9 Downloads

May 6th, 2009 · Mac OS X, Tools

Windows 7 Release Candidate is now ready for beta testing and will be available until July 2009.

Here’s what you need to have:

* Internet access (to download Windows 7 RC and get updates)
* A PC with these system requirements:
o 1 GHz or faster 32-bit (x86) or 64-bit (x64) processor
o 1 GB RAM (32-bit) / 2 GB RAM (64-bit)
o 16 GB available disk space (32-bit) / 20 GB (64-bit)
o DirectX 9 graphics processor with WDDM 1.0 or higher driver

Ubuntu 9 also is now available for download and was reported to be “as slick as Windows 7 and Mac OS X”.

I wonder when we can see a preview of Snow Leopard

→ No CommentsTags: ···