Jun 6, 2009

Another day in a developer's life....

Yesterday was a frustrating day.
By the morning I started to work (pairing with a really smart friend) on an apparently simple task: to automate the process of starting an internet explorer (ie) instance, navigate to a specific page stored on the local machine, wait for some processing to finish (notified by the page) and grab the results. Having some years of experience with Microsoft technologies, mainly developing COM components, and aimed with (lack of) humbleness I started to write a jscript script to drive IE through automation, after all how hard could that that be? Indeed, the first part was really easy:
var browser = new ActiveXObject("InternetExplorer.Application");
browser.Visible = true;
browser.Navigate("http://programing-fun.blogspot.com");
I run the just finished prototype and the browser opened, navigating to the desired page. I was really happy (and thinking how I am smart). So far, so good. But things started to get weird really fast. Even having a good grasp on IE's object model (I don't know it by heart) I failed miserably to retrieve a reference to a page element:
var browser = new ActiveXObject("InternetExplorer.Application");
browser.Visible = true;
browser.Navigate("http://programing-fun.blogspot.com");
while (browser.Busy) {
WScript.Sleep(10);
}
var element = browser.Document.getElementById("some-id");
After some time we decided to give up on using jscript and switched to C#, so I created a Windows Form application to host WebBrower control (hum... someone said IE?) but we kept seeing strange behavior. For instance, the page we were trying to load hosts a Silverlight application but IE insisted that we should install Silverlight; WTF? I do have Silverlight installed !!!

Well, at that time I was not felling so smart anymore; and since it was almost lunch time we decided to continue latter.
When I got back to work I was determined to get it working so I did what any reasonable developer does in such situations: I decided to do something else :) and I ended up watching a screencast about how to improve the experience for users that don't have Silverlight installed; hum.. interesting. 

The presenter suggested to disable the Silverlight add-on (instead of uninstalling it).
Great! Maybe the add-on was just disabled (due to some stricter security configuration when launching IE through automation).

Why I haven't thought about this before?
I started my application (C#) as fast as I could and a new browser appeared (in the same way as before), then I went to the add-on configuration dialog and voilà! There was no Silverlight add-on listed (how could I enable/disable it?).

So the problem was that, for some reason, IE was not even considering Silverlight add-on to be installed (but that was what IE was trying to say me all the time no?).


Then I launched IE manually (clicking on its icon on desktop) and opened the same add-on configuration dialog. This time I could see that Silverlight (and a lot of other add-ons) were installed and enabled.


Well, now I was starting to fell better :). But I still had to understand why I was getting different behaviors depending on how I launched IE. After some head screeching followed by some thinking and some extra searches I do figured out the issue, but that's the subject of a future post :)


Have fun! 


Adriano

Mar 23, 2009

Db4o with Visual Studio 10 / .Net Framework 4

Hi.

When Microsoft announced they would make available VS 2010 CTP I got curious about how easy (or hard) it would be to compile / run Db4o and also how OMN would behave in this early CTP (would it just work, without even require a recompilation? If not, how easy/hard it would be to make it work if possible at all, etc).


Well, yesterday I managed to download the CTP; after extracting the files (24 Gb!!) I just took OMN 2008 installation and give it a try. It was really amazing. The only change I've applied was to update the file %ALLUSERSPROFILE%\Application Data\Microsoft\MSEnvShared\Addins\OMAddin.addin in order to change the target VS (OMN 2008 will set it to 9.0 but VS 2010 is 10.0). 


After this change I just fired up VS and OMN addin was there, working with no issues (as far as I tested :)) as you can see in the screen shot bellow. Cool.



Next step was to load Db4o 2008 solution file; VS 2010 asked whenever I'd like to convert the solution/project files to the newer version; I just consent to that and when it finished converting I just run Db4o Tests. 

This time some tests failed due to missing jars (I didn't run a full build) required to run Java/.Net compatibility tests; besides that expected failure,  only one test failed (I just disabled it for now).


My next steps will be:

  1. Try to understand / fix the falling test.
     
  2. Prepare the environment to at least run the target "build-before-checkin"  defined in build.xml (and uncomment any test commented out to make the tests pass).

  3. Reason whenever it makes sense to use some of C# 4.0 / .Net Framework 4.0 new features (for instance dynamic types) and how Db4o handle them.
Since these will require more time to investigate / test I'll leave them for a forthcoming post.

Adriano

Mar 21, 2009

Benefits of working from home - Epilogue

After 9 posts in this subject (BTW, I have written this post long ago) I am going to finish it... and the big question is:

Did it worth?

Well, to answer this question I pondered on various aspects: It allowed me to move to a smaller city, closer to my wife's parents, a less violent, less expansive
city, etc; it gave me the chance to spend more time with my family and a lot more benefits!

So, IMO it really worth the move! Even missing some "usual work style", I am pretty happy working with very smart people, in a really cool product, applying really nice development methodologies and last, but not least, being able to organize my own time :).


I don't know how long I'll be working with these stunning guys, but I do hope I could be there for a long time ;). There's just so many things to learn yet!

That's it ;)

See you all.

Adriano

Mar 10, 2009

Automating Skype through COM

Wow.. finally a technical post again :)

Those of you who knows me knows that I am a firm believer of component technologies.

Personally I really appreciate Microsoft's COM technology; ok, it does has it drawbacks (as everything in life) but when used correctly it proved to be a very powerful way to support software automation and extensibility. Let me briefly explain what those funny words means for those who don't know yet.

Basically, software automation is the process of a software controlling another one. For instance, if you have Microsoft Office installed it's possible to write a program (even a JavaScript script) that creates a Word Document through automation, i.e, your program may "control" word (and Excel, Power Point, etc). This kind of flexibility can be very helpful in some scenarios.

By extensibility I mean ways of extending a given application. A good example is Windows Explorer; it's possible to add new items to a context menu (in the same way 7-Zip and many other applications do) simply by implementing an specific COM interface (and registering your component of course).

These are just 2 examples of what's possible; of course other softwares also support some level of automation (for instance Adobe Acrobat).

In this post I just want to talk (again, briefly) about Skype and how it's possible to extend it through COM (Skype also supports automation through Java, XXX, etc).

First let me just explain that the possibilities are infinite; what you may want to do with automation is not my business :); all I can say is that if you think a little bit you'll be able to find some nice use for skype automation.

For instance (as I said in my last posts) I use Skype heavily on my work to communicate with other team's members. At least once per week we do a Skype meeting in order to decide what we're going to do in that week; to manage these tasks we have a "queue" of tasks in our Jira installation.

One annoyance during this meeting is that once someone decide he wants to take a specific task the process involves at least 2 steps: to announce in the chat meeting and going to the browser to update Jira.

Since it's possible to automate Skype I wrote (to be more precise I am debugging it right now) a "plug-in" that simply keeps listening all chat messages and react accordingly for specific patterns; for instance if I want to take a task (let's say TSK-1) I may just type:

$jira assign TSK-1 myself

This way I announce to the team and update Jira at once :) (I don't need to go to the browser anymore)

The plugin is "smart" enough (through configuration) to figure out who I am ("myself") and to go to Jira (through a WebService) and update the specific issue (task).

And this is only a basic example about what can be done (the sky is the limit :).

For more information about Skype automation visit
https://developer.skype.com/.

If you want to take a look into this plugin, just grab the code at: git@github.com:adrianoc/binboo.git or browse the code online at https://github.com/adrianoc/binboo (just keep in mind that there're lots of assumptions/dependencies to our Jira installation but I guess one can learn a lot about how to integrate to either Jira or Skype). 


See you.

Adriano

Jan 21, 2009

WIX Tips

Hi.

Since I have been playing a lot with MSI installers latelly and I'd like to share two tips with those authoring Windows Installers with WIX:
  • You can get a lot of information by running your installation package through msiexec:

    msiexec /i CustomAction.msi /lvx log.txt

    The command above just runs CustomAction.msi logging everything including the kitchen sink :)

  • You can use 7Zip to open msi files (and ofcourse, extract content from it)
Happing programming ;)

Adriano 

Jan 7, 2009

First impressions of Windows 7

Hi,

As a computer addicted I decided to download Windows 7 Beta 1 (32 bits) and give it a try (if you are interested, just search for "Windows 7 Beta1" in your favorite search engine and I am sure you'll find your way :)

In this post I want to present my first impressions about it. Please, note that I am not an expert in this subject and also that this is just my opinion based on my perception without any pretension regarding "data" accuracy.



I need to admit that I am impressed about it. My first impression is that it is way faster than Vista when running on the same machine; at least it is pretty responsive. Bellow you can find a list of items that caught  my attention and won my respect (at least for now):



  • Fast Installation: ~ 20 min for a full install.

  • Few prompts during installation.

  • No problems with device drivers at all (Video, audio, keyboard, etc)
    • Some devices already have preliminary versions for Windows 7
      I guess that this is more a result of not introducing deeper changes to the driver model (Vista introduced really deep changes there).

  • There are some compatible antivirus already.

  • Looks really fast on a relatively old hardware

  • I really liked the UI changes (even being minor changes).
     
  • Just a few UAC prompts
    • Using it for some time I have seem UAC prompts only for software installation.

  • IE 8 is not as fast as I'd like it to be. (But I've already installed firefox)
 Bellow you can see a screen shot.


Well, that's it for now.


Adriano

Storing PowerShell objects into a Db4o database

Hi,
First of all, Happy New Year :)
If you use both PowerShell and Db4o you maybe interested in this post.
Best
Adriano