Montreal Bus Stop Locator Site Updates

By Jay at September 07, 2008 09:06 Tags: ,

Cet article est disponible en français ici.

So far, the response has been great for my little utility, even though I'm not making an active advertising.

Using some Microsoft terminology, I'm dogfooding my own application and I found a few points that could be enhanced a bit :

  • Now, if using Google Gears, you are not automatically redirected to the stop list for your location. You simply see a small map of where you're supposed to be, and you're offered a other button to choose to use that location.
  • Some error messages are displayed when typing incorrect or missing data. That could be confusing...
  • All maps are now using all the available width of the screen. That means that the image is not resized poorly on a mobile device. Still, I wonder how the iPhone wil behave with this...
  • I fixed a bit the distance display to display Km instead of meters if appropriate, even though if you are in an other city, you'll still be offered some reaaaally long distance.
    I'm still wondering if I need to filter out people that are outside Montreal. The point of this site is also to be a technological proof-of-concept for GeoLocation, so even if the distance is not usable, it's still a valuable information.
  • I've also added some street name samples to help people that are not from Montreal to see what the site can do. I've taken a random intersection and bus stop code that can be typed in directly.
  • I also made some XHTML compliance, for what it's worth :)

Now, I think I'll try to make sure that Google search will find the site in both French and English languages because right now, I'm having the same problems I did have with my Remote Control software pages. Google's crawling without specifying a language, so for this site, English is going to come out, since it is the default language. Maybe I'll add a "/fr" and "/en" virtual base for each of them.

I'm always interested in any suggestions or bug reports !

.NET 2.0 InternalsVisibleTo Attribute and Unsigned Assemblies

By Jay at September 02, 2008 07:19 Tags:

Ce post est disponible en francais ici.

In a recent project, for the purpose of unit testing, I had to use the InternalsVisibleTo attribute, which extends the scope of the internal qualifier. This allows the separation of the unit testing code assembly from the actual code, without publishing the internals to the "public". This way, you can avoid shipping your unit testing code.

This is an interesting attribute from many points of view, but when using it, you may face this nice error message :

error CS1726: Friend assembly reference 'Dummy' is invalid. Strong-name signed assemblies must specify a public key in their InternalsVisibleTo declarations.

Problem was, my current assembly nor the target assemblies were signed. I tried adding a dummy PublicKey or PublicKeyToken as indirectly suggested here and here, but as many people out here, I don't want to mess with assembly signing at this point of my project.

It turns out that the compiler considers your assembly as "signed" if there is either an AssemblyKeyFile or AssemblyKeyName defined on the assembly, even though both of them are empty. 

So, to be able to use AssemblyKeyName InternalsVisibleTo with unsigned assemblies, just remove AssemblyKeyFile or AssemblyKeyName attributes if you don't use them.

Using Google Gears to find Montreal's Bus Stops

By Jay at August 31, 2008 20:08 Tags: , ,

Cet article est également disponible en francais ici.

It's been a while since I've posted on this blog. This time, I will not be talking about bluetooth, but still about some .NET powered code :)

I've been busy lately, but I've found some time to work on something that will help me a lot, and I think a lot of Windows Mobile users and mobile users in general.

Montreal's Bus network is somehow large, but its representation in the digital world is quite poor, and inexistent when talking about mobile internet. The web site in question is generating some quite large pages and is not suited for mobile web browsing.

Most of the time, you may want to know the schedule of the next bus, and this is quite hard to get this way.

There's been some effort lately to offer this kind of service on the iPhone, but I wanted to give the opportonity to other users to have the same information, with some Geo Localization features.

This is where google gears comes into action, where their latest release offers a Geo-Location API, which approximates a position using the nearest GSM cells location. Unfortunately, it only works on Windows Mobile devices. But don't worry, if you don't have a Gears enable device, it will still work ! You'll only have to type a bit, by entering your streets intersection.

After getting that location, I'm querying a database (using Linq to SQL) to get the nearest Bus Stops and their next schedule. I'm also querying Google Maps to get some markers pointing at the bus stops. That can be helpful since the Geo-Location is only an approximation by nature, because of the GSM 'triangulation'. It can also be used to query the schedule of a specific bus stop, using the number placed at the bottom of the bus stop signs. A small plus here, compared to the original site, is that schedules from the past half hour are still visible, making possible to have determine if a bus has missed its schedule using a great long street.

Anyway, if you're in Montreal and have an internet connected device (or a normal PC), give it a try by connecting to this adress : http://jaylee.org/stm

Any comments or suggestions are welcome !

ILogicalThreadAffinative, again.

By Jay at May 14, 2008 19:12 Tags: , ,

Ce post est également disponible en francais. 

In a previous post, I talked about a feature of the .NET framework that allows to automatically pass information from a thread to any thread it spawns.

It turns out that not only the Call Context flows to the thread pool, but it also flows to any System.Threading.Timer and to IO completion related threads, such as in Sockets.

I was taken off-guard by the fact that in early stages of the server-side remoting pipeline, there were already information in the CallContext before the incoming message was deserialized. But the content was not exactly what I was expecting; it was the data that was in the CallContext when RemotingConfiguration.Configure() was invoked.

This makes sense, all the sockets used by TcpChannel or HttpChannel are created when calling this method, and asynchronous operations are started at this time. So, to avoid having the data to flow to the other side, there are these two methods on the ExecutionContext class to Suppress the flow and Restore it, which can prevent temporarily the Call Context from flowing.

IEnumerable<T>.Any() vs. IEnumerable<T>.Count() != 0

By Jay at May 10, 2008 11:10 Tags: , ,

This post is also available in french here. 

After reading this post from Eric Lippert, and reminding me that in the samples for this post, I'm using IEnumerable<T>.Count() where I'm actually not using the return value, therefore I'm enumerating through the whole collection for almost nothing.

I could have used IEnumerable<T>.Any(), which after looking at the IL code, just starts the enumeration, and stops just after one element if there is one and returns true, or if there isn't, returns false.

This is more effective, even without PLinq :)

Bluetooth Remote Control for Windows Mobile 0.9.0

By Jay at March 30, 2008 21:27 Tags:

Yet another release of Bluetooth Remote Control for Windows Mobile.

This time, I've added two features that were requested for a long time, which are the ability to control application that I did not include out of the box, and the ability to use the device as a simple mouse and keyboard device.

About the first part, there is now a configuration file that allows the addition of new applications by defining each and every command that can be used on the mobile side, and their corresponding action. I intentionally did not comment the file, this is not meant to be modified by a standard user, but rather by an experienced user or developer that wants to control a custom application. The configuration file will hopefully be really simple to understand for a developer. So, if you understand how this file works, just feel free to add a new application, or update an existing if it does not fit your needs.

Now about the part with the keyboard and mouse. I added a new "application" which actually is not, which is basically a pass-through for mouse and keyboard actions. You'll be able to move your mouse and type in any key you want in the focused window. On my TyTN II, the key mapping is a bit funky when using the function key, but I'll try to fix that for a future release.

Both features are fairly stable, but I suspect minor issues to come up as users are using it. Feel free to comment !

Download version 0.9.0 at http://www.jaylee.org/remotecontrol.

Here is the change log :

  • Fixed warning message when ActiveSync is not detected to install the mobile side program.
  • Added application definition file.
  • Added screen control application.
  • Fixed Widcomm PC side support when transmitting large chunks of data.

Using a real USB bluetooth device in Virtual PC 2007

By Jay at March 25, 2008 20:03 Tags: , ,

This is one of the biggest missing features of VPC 2007, the lack of USB passthrough support. The lack of a proper snapshot feature is annoying too, even though it is possible to move Undo Disks to simulate snapshots. But I still prefer VPC 2007 over VMWare, mainly because I find the latter to be too intrusive and unstable...

Anyway, I was looking for any update to VPC 2007 for the support of USB devices, in one form or another, maybe with a beta VPC 2008 or 2009. This is still not happening but, I came across this software, Usb over Network, which does exactly what I need to do.

This software is particularly easy to install, and it works right after being installed. I'm able to "export" my integrated USB Bluetooth dongle to the VPC, and it works like a charm ! I'm able to run both bluetooth stacks in controlled environments, without crippling my main OS with multiple stacks.

A really nice software, not free, but really useful if you're depending on USB hardware and you want to test it in a virtual environment.

About me

My name is Jerome Laban, I am a Software Architect, C# MVP and .NET enthustiast from Montréal, QC. You will find my blog on this site, where I'm adding my thoughts on current events, or the things I'm working on, such as the Remote Control for Windows Phone.