Archive for February, 2006
T-Mobile SDA review, positives vs. negatives
Posted by Brett Robinson in Uncategorized on February 17th, 2006
So, I purchased the T-Mobile SDA that I wrote about last week and I have had it for about 5 days. Here are my thoughts on the phone…Overall its great. I have enabled the wi-fi and have been able to connect to a network and browse the internet, etc. Its pretty neat. When riding on the train I enable the wi-fi and watch the networks pop in and out. The camera and video have great quality. I have not had time to hook up the email yet to our exchange server, but from what I have read it is a pretty simple thing to do. Here are the negatives, the first is response time. When you try to navigate sometimes the phone is unresponsive for a few seconds and then it catches up with the clicks by doing 10 things in 1 second. The little knob that you’re supposed to navigate with is kind of hard to push in the right direction and click things. For example, you’ll select an item and click the button thinking it will open the application…but it doesn’t and maybe navigates to the item next to it. The last negative thing is memory. There isn’t much so a mini-SD is almost necessary to hold songs, application, etc. Overall a good purchase and I’m just getting started (wrote the first sample phone application yesterday and deployed it to the windows mobile 5.0 emulator in VS 2005).
.NET Custom Installer for multiple environments
Posted by Brett Robinson in Programming on February 15th, 2006
Deploying applications in a distributed environment and creating a standard procedure for the IT staff can be a tricky thing to do. It often involves people outside of your development group and an understanding of what the installation is supposed to do. One major issue that developers worry about is their config file settings and placing the proper values in the config as they move through different environments. This begins the debate between who should maintain the configuration files. Should the developer be responsible for changing the config file in production or should the Network Admins be the ones responsible for changing config values? There are many opinions on who should change the values and how it should be done. I answered this question in a solution that I prototyped that involved a custom dialog during the installation process that would allow an non-IT professional to install the application to the proper environment (if told what environment they are installing to). The first step involves adding a few elements in the config file that specify settings for each environment like so:
<?xml version=”1.0″ encoding=”utf-8″ ?>
<configuration>
<SIT>
<appSettings>
<add key=”user” value=”Brett”/>
<add key=”DbInstance” value=”SIT_BRETT”/>
</appSettings>
</SIT>
<UAT>
<appSettings>
<add key=”user” value=”Brett”/>
<add key=”DbInstance” value=”UAT_BRETT”/>
</appSettings>
</UAT>
<PROD>
<appSettings>
<add key=”user” value=”Brett”/>
<add key=”DbInstance” value=”PROD_BRETT”/>
</appSettings>
</PROD>
</configuration>
Once you have this in place you can start building your custom installer class which will override the install command from the installer to do some custom stuff. Start by creating a class project that inherits from the installer class. Then override the install function and create your custom function. From there I used the XmlDocument class to load in the config file and determine which environment setting was passed through from the installer. I then remove the other environment settings leaving the proper config settings in place. Here is the code for the class, that I called EnvironmentInstaller, that inherits from the installer class:
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Configuration.Install;
using System.ComponentModel;
using System.Xml;
using System.Reflection;
namespace MyInstaller
{
[RunInstaller(true)]
public class EnvironmentInstaller : Installer
{
private enum Environments
{
SIT = 1, UAT, PROD
}
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
Environments environment = (Environments)Convert.ToInt32(Context.Parameters["ENVIRONMENT"]);
setProperEnvironment(environment);
}
private void setProperEnvironment(Environments environment)
{
// load config document for current assembly
string[] configLocation = loadConfigDocument();
for (int i = 0; i < configLocation.Length; i++)
{
XmlDocument doc = new XmlDocument();
doc.Load(configLocation[i]);
XmlNode configurationNode = doc.SelectSingleNode("//configuration");
XmlNode currentEnvironmentNode = null;
XmlNode environmentNode1 = null;
XmlNode environmentNode2 = null;
switch (environment)
{
case Environments.SIT:
currentEnvironmentNode = doc.SelectSingleNode("//" + Environments.SIT.ToString() + "");
environmentNode1 = doc.SelectSingleNode("//" + Environments.UAT.ToString() + "");
environmentNode2 = doc.SelectSingleNode("//" + Environments.PROD.ToString() + "");
break;
case Environments.UAT:
currentEnvironmentNode = doc.SelectSingleNode("//" + Environments.UAT.ToString() + "");
environmentNode1 = doc.SelectSingleNode("//" + Environments.SIT.ToString() + "");
environmentNode2 = doc.SelectSingleNode("//" + Environments.PROD.ToString() + "");
break;
case Environments.PROD:
currentEnvironmentNode = doc.SelectSingleNode("//" + Environments.PROD.ToString() + "");
environmentNode1 = doc.SelectSingleNode("//" + Environments.SIT.ToString() + "");
environmentNode2 = doc.SelectSingleNode("//" + Environments.UAT.ToString() + "");
break;
}
environmentNode1.ParentNode.RemoveChild(environmentNode1);
environmentNode2.ParentNode.RemoveChild(environmentNode2);
XmlNode appSettingNode = currentEnvironmentNode.FirstChild;
configurationNode.ReplaceChild(appSettingNode, currentEnvironmentNode);
doc.Save(configLocation[i]);
}
}
private string[] loadConfigDocument()
{
Assembly callingAssembly = Assembly.GetCallingAssembly();
string location = callingAssembly.Location.Replace(callingAssembly.ManifestModule.Name, "");
string[] files = System.IO.Directory.GetFiles(location, "*.config");
return files;
}
}
}
When you compile this it will produce a dll file that you will include in your setup project. First add a new Setup project into your solution from Other Project Types -> Setup and Deployment in .NET. The first screen is the File System screen. Add in a your project output and any other files that you need to deploy from your solution. Last, add in the dll from the class project that you built before.

Now we need to add in a custom dialog that specifies which environment we are deploying to. Click on the User Interface editor:

and add a new Radio Buttons (3 buttons) dialog:

Change the properties of the dialog to look like the following:

Next click on the custom actions editor, and add a new action to the Install directory. Choose the dll that you included in the File System screen.

Change the properties to look like the following:

What you are doing here is specifying the enter button of your new dialog to send the radio button results to the custom installer class we created as a parameter in the EnvironmentInstaller class.
Click the save all button and rebuild the solution and the setup project. Now when you install the application you will see this screen:

You can download the code sample here: My Installer demo [ 497 Downloads ]
Smartphone is finally here for T-Mobile USA
Posted by Brett Robinson in Uncategorized on February 1st, 2006
I’ve been looking at getting a smartphone for some time and it seems the time is almost here. T-Mobile announced last month that they are finally releasing the MDA and SDA in the US. These phones have been over in Europe for some time now, and after many months of rumors and leaks about the phones coming to the US it seems they are finally here (almost). You can pre-order the phone once they are available from T-Mobile. Before this I almost broke down and purchased an i-mate or Qtek on Expansys. But, I’m glad I waited because the new SDA has tons more capabilities. It has has GPRS/EDGE/WiFi capabilities, bluetooth, and runs on Windows Mobile 5.0. I’ve been reading about the .NET Compact Framework bluetooth library and hope to create a bluetooth application once I get my phone - right now the library is only available to MSDN subscribers.
Here’s the official T-Mobile announcement - click it to sign up to get notified of the release (I cropped the photo just to show the SDA):

I’ll write more once I get the phone and can try out writing a bluetooth application.
The Channel 9 Wiki for Mobile Developers has pretty good information about Windows Mobile development.
Recent Comments