2010/07/18

The Saga of COMException (0x800736b1)

So I had a very lovely weekend being sexually assaulted by a pesky problem while installing an ASP.NET application on a Windows XP IIS server.


Server Error in '/AppName' Application.


This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. (Exception from HRESULT: 0x800736B1)



Exception Details:System.Runtime.InteropServices.COMException: This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. (Exception from HRESULT: 0x800736B1)


Ok, this is lovely. Tracing the error code was pretty straight forward and pointed to the lack of VC++ Redistributable DLLs on the target machine. They are present on the developer box, but are missing on target. Sounds easy enough, downloaded vc_redistx86.exe , installed - same result.

Excellent. So, using depends.exe, I checked that the DLL in question is looking for msvcr80.dll and friends. Curiously enough - they were installed on the system, but the problem persisted, the application just didn't pick them up.

So I dug some more, and came across a folder \Windows\WinSxS (http://msdn.microsoft.com/en-us/library/aa376307(VS.85).aspx). It's Microsoft's solution to DLL Hell. There are several versions of the same CRT DLLs, in subfolders with different version names.

Which pointed me to the fact that it's not that the DLL is missing, but it's of incorrect version. So what was left is to discover how exactly does the application select which DLL to load. (it's obviously not by name!). So after frantic Google searches I came across a beast whom I met before but didn't pay attention to - "XP Manifest". 

It's a XML file which is embedded inside the application/DLL as a resource, and can define properties like 'Dll dependency'. So a quick run of ResHacker, patching the XP Manifest, saving the new app, re running, seeing that it works and then promising my self to tear away the nads of whomever though it would be a great idea to make me spend my weekend tracking this shit, and not just showing me a freaking help message!

2010/07/05

Bitmap Button in Blackberry

I won't bitch about the state of Blackberry UI framework, just mention that there's isn't a standard button class that supports images. WTF?
In any case, here's the code that implements one.

Open an external browser on Android

Ok, so I wanted to open an external browser from my Android application. Crazy, right? Anyways, after some searching and trying to read almost empty Android SDK docs on the subject, I came across this golden turd:


        try{  
            Intent i = new Intent();
            ComponentName comp = new ComponentName(
                             "com.google.android.browser",
                                    "com.google.android.browser.BrowserActivity");
            i.setComponent(comp);
            i.setAction("android.intent.action.VIEW");
            i.addCategory("android.intent.category.BROWSABLE");
            Uri.Builder z = new Uri.Builder();          
            i.setData(z.build());
            getContext().startActivity(i);
        } catch (URISyntaxException e) {
                e.printStackTrace();
        }



At this point I lost all faith in humanity and all that's sacred.
Come on people, there must be a better way!

And here I come to save the day :) The code is actually very short and simple:


getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));