February 2008 - Posts

Having trouble creating an MSI for Windows Mobile apps?
26 February 08 12:16 PM | dsamuilov | with no comments

Well, you are not the only one... Creating an MSI file for application distribution is really simple, but when you want to distribute an application that runs on the Windows Mobile environment, it is not that simple any more. This is especially true if you are new to Windows Mobile development.

Why a CAB if I want an MSI?

The answer is "multiple hardware platforms", you obviously want to deliver a well developed solution, and your application will probably be rolled out to different hardware. What you want to do is create a CAB file containing the application as compiled for that particular platform (Windows Mobile Professional vs. Windows Mobile Standard). You may be even looking at releasing the application to different OS versions and even different processors. Well, that might require some tweaking on your part to deliver the best performing application for each platform, OS, and processor... bummer.

So the best approach is to create multiple CAB files, each one with all the corresponding application requirements. and finally create the MSI file that contains all of them. Easy, right? not so fast...

Once you have all the CAB files you need, you can create an INI file that lists all the mutually exclusive CAB files in the package. For example DotNetCF would be one package, SQL2k5 would be another and the third one would be your application. Each of those packages would be a set of CAB files of which only one would be installed to the mobile device. In other words, you would be installing 3 CAB files, one from each package. However, each package will have many files; as many as different platforms you are deploying to. You will create an INI file for each package you want to create. This INI file will have the list of all mutually exclusive CAB files in that package.

While you can create an MSI project pretty quick, the MSI projects are targeted at delivering the application to a PC and not a mobile device. So you need to "trick" the MSI installer into not only copying the cab file into a PC folder, but also running the application installer provided with ActiveSync (yes, the one that runs when you add/remove programs in ActiveSync). Coupled to that, you may need to distribute several other packaged CAB files such as the .Net Compact Framework, SQL Server Compact, etc. The default project for creating MSIs only has automation to copy files in certain folders, so you can use code in a custom installer class where you can specify to run CEAppMgr.exe for as many CAB packages as you want.

To make things short, you would be running a call to unpack the right CAB file from each INI file you created. CEAppMgr will take care of deciding which one is right for your device, out of all the options you list in the INI file, so all you need to do is make the right call in that custom installer.

Now, out on the web I have noticed that people are having trouble making the right call. This is because they are not allowing the process to wait enough time to call it again for unpacking the next set of CAB files listed in the next INI file... that is because in the call, they need to use .WaitForExit() at the end of the call. The call in the custom installer should look like this:

System.Diagnostics.Process.Start(appMgrPath, "\"" + Path.Combine(installPath, CEAPPMGR_NETCFXv2_INI_FILE) + "\"").WaitForExit();

System.Diagnostics.Process.Start(appMgrPath, "\"" + Path.Combine(installPath, CEAPPMGR_SQLCE2K5_INI_FILE) + "\"").WaitForExit();

System.Diagnostics.Process.Start(appMgrPath, "\"" + Path.Combine(installPath, CEAPPMGR_INI_FILE) + "\"").WaitForExit();

If you have to make several calls, and you don't use "wait for exit", then the process may overlap and fail from time to time. It will not fail every single time, but it will not work correctly every single time.

Got the MSI... but need to rebuild my projects: how?

This is the really easy part. If you have all projects as part of a solution, then it will be easy to rebuild each project (application, then CAB, then MSI) and just pick up the MSI file from the Release folder under the MSI project folder.

Now that you have the basics, lets get to build that MSI!

Don't hesitate to post your comments here or even better: go to our forums for posting specific help with your project's MSI package.

BlueKatana Tool-Applications for Windows Mobile 1
25 February 08 04:10 PM | dsamuilov | with no comments

Our team has re-released some of the applications created recently. They were created as a training exercise by our team members. Each team member has chosen a pet project and executed the training to completion by creating their application. All proceeds go directly to the developers.

Please be on the lookout for more small tool-applications from our team. It is our intention to keep posting more applications as we move forward.

So far we have posted:

Tip Calc v2.0: Enter your meal total, the percentage you want to pay for the tip and how many people will pay for the meal. The application calculates the total and the amount to be paid by each one.

 

Password Generator v1.5: Generate random passwords with or without additional characters such as numbers and punctuation signs. Passwords are created and available to be copy-pasted to your favorite applications.

 

Mortgage Calculator v1.2: Calculate your monthly payments throughout the life of your mortgage (interest, principal and monthly payment). Displays balances, subtotals for the interest and principal for each year and totals to have paid at the end of the mortgage.

Why you need to know about SQL Server Compact Edition (SQL CE)?
14 February 08 09:01 AM | dsamuilov | with no comments

So you are a developer who works on applications that run on the desktop; or you are a project manager who has only heard of SQL Server Compact Edition... In any case, if you have hardly heard of SQL Server CE, or you are assuming that SQL Server CE runs only on portable devices, then you should read on to learn about some new powerful options available for your environment of choice.

Well, SQL Server CE in not only intended for devices who run on the Windows CE platform (Windows Mobile, Xbox 360 and many others among then) but also for PCs running XP and Vista:

WHAT? You didn't know? Never mind, keep reading then...

While SQL Server comes in many flavors, SQL Server Express is not the smallest of them all. Yes, it's free and it can run in your desktop if you want it... but do you really want to run a SQL Server on your desktop? Is that the smallest you can go?

While you should use a service whenever appropriate, common sense will indicate you to use something even smaller if the application only requires a store for data that can be easily accessed. Yes, you could access that application data if you store it in plain (or custom) data files, or you could build your own XML data structures, but those are plain ASCII file with either little or no security. If you secure them with encryption services, one of the many available APIs, accessing those files will happen at a much higher cost than your plain ASCII counterparts.

So, This is where SQL Server CE comes along to the rescue. SQL Server CE keeps the name "SQL Server" for consistency's sake but is smaller than a server. In fact, it does not even run as a standalone service, it runs in-proc with your application only when instantiated and provides many of the existing features in SQL Server while keeping execution cost at a minimum. There are versions of SQL Server CE available for the PC and Windows CE (where it originated), but Microsoft saw a strong potential in this tool for the desktop and pushed for its further development as a clear alternative to a full blown service.

SQL Server CE has a smaller footprint than a regular SQL Server service by having some limitations such as running in-proc with your application, not having stored procedures or views. However, running in-proc could be seen as a powerful feature instead of a limitation, because you don't really need to have your server running and eating precious CPU cycles off your desktop/mobile device all the time. Instead your SQL CE will behave as if it "wakes up when needed" creating the illusion of an always available, but not always eating processor cycles. Additionally; even though it runs in-proc; you could still have multiple applications within a single computer/device accessing the same SQL CE database, or you could have multiple clients accessing a shared database. Again, please have in mind that this version is intended for use where you would have not used SQL Server and would have used a different type of data store. It can be taken to extremes, but at those extremes, the functionality needed may overlap with other SQL Server flavors and you may want to choose those. In summary: choose wisely.

Many features can be brought up as being pretty cool in SQL Server Compact Edition, however; in my opinion, one of the most important strengths of this tool is the ability to synch back to any other SQL Server. This would enable you to store only the part of the corporate data that is needed as a distributed portion right where your application resides and only on scheduled intervals or whenever triggered have the databases synch up for replicating the data in, out or both ways. You could have a complex merge replication scheme to help your different locations see only what pertains to their location without having to distribute a server to them. This would allow for distributed applications with smartly-distributed databases without the need for server distribution... in corporate terms that could amount to an amazing amount in savings!

If that wasn't enough; here's the best part: IT'S FREE! Yes, you read it right, you can download SQL Server Compact Edition for free from right here:

Inyeccion de SQL Server
12 February 08 07:21 AM | dsamuilov | with no comments

Una amiga mia ha experimentado algunos problemas en su sitio web. Alguien le ha estado haciendo un lio terrible con el uso de Inyeccion de SQL Server... Por favor lean el articulo que escribi al respecto en el foro de bases de datos si se encuentran en una situacion similar. La solucion no es 100% a prueba de hackers, pero al menos va a hacer que la implementacion de inyeccion de SQL sea mas dificil para la gran mayoria de los hackers.

SQL Server Injection
11 February 08 03:16 AM | dsamuilov | with no comments

A friend of mine has been experiencing some trouble with her websites. Someone has been making a mess off of her websites by doing SQL injection... Please read the post I submitted to the Database forum if you are faced with similar behavior from one of your websites into your database(s). The solution will not make your website absolutely 100% hacker proof, but it will make things pretty difficult for using SQL injection in it.

Innovate ON Windows Mobile
07 February 08 03:11 AM | dsamuilov | with no comments

Independent Software Vendors (ISVs) have built somewhere around 19,000 applications for Windows Mobile. Microsoft has built a website called Innovate ON Windows Mobile. This portal is designed as part of the Microsoft Partner Program. It is meant for helping ISVs in the development, testing and marketing processes required for creating software. It covers from the very basic resources such as what tools to use and how to install them to access to mobile webcasts, events, etc.

InnovateONWindowsMobileThe website comes really handy if you are serious about building software for Windows Mobile because it also provides information on testing resources and how to obtain the "Designed for Windows Mobile" certification. On the marketing side, it also helps out by providing access to the Microsoft Certified Software Catalog (to which your software has access after getting the Windows Mobile certification) and tools to sell your application online with the help of Software Distribution Partners such as Handango, MobiHand, Motricity, etc.

To participate in this program all you need to do is enroll. Becoming a member will qualify you for additional exclusive benefits such as Free Test Vouchers and Tech Support. If you or your company are not a Microsoft Partner, join now for all these benefits.

.Net Compact Framework 3.5 Redistributable Available for Download
05 February 08 03:09 AM | dsamuilov | with no comments

Yes! It is ready and available for download here! It's been out there for about a month actually, but everything has been so hectic lately that I had no time to mention it or add the link on the BlueKatana website. This package contains the runtimes and libraries for version 3.5 with support for applications developed for .Net CF 3.5, 2.0 and 1.0. Very cool new features such as WCF (Windows Communication Foundation), LINQ, SoundPlayer and many more features. Please have in mind that if you want to develop for version 3.5 then you must use Visual Studio 2008.

South Florida Code Camp 2008 a Success
03 February 08 07:17 AM | dsamuilov | with no comments

Yesterday was a long day, I woke up at 5 AM so that I would make it on time to the Code Camp. Everything went great, I met with Silvia at the event. She is a friend of mine who was also going to the SFCC, chatted for a bit and then went on to the speaker room to make sure that everything was prepared for the marathon I was about to start (4 presentations - 2 in English and 2 in Spanish).

Our friends at http://fladotnet.net did a great Job at organizing this event. We had a great attendance: 617 people registered early in the morning at the event. We had enough time for breakfast and lunch, where we could mingle and talk to everyone there. Here are some pictures:

Commons1 Since I had everything prepared, I went on to the class where I was scheduled to start with my first presentation.

I had prepared the same two presentations both in English and Spanish, which was a little bit easier than just preparing four presentations. My subject this time was focused on preparing an introduction to Windows Mobile aimed at seasoned developers that had no prior experience building apps for that platform. The second one was aimed at people with a little bit more experience with the Windows Mobile platform and we focused on what's new in the .Net Framework 3.5 Commons2and the benefits of using managed code.

It is very refreshing to see how people's faces light up when they realize that not only they can use the same programming language they've been using for years, but also that they don't need to get a new tool. They get it right away and they can start programming as soon as they get back home.

The presentations went almost without a problem, except one minor thing; I forgot to turn off my screen saver with personal pictures of my family, and when I went on for a few minutes without moving to the next Presentation1slide, or I was asked some questions, the picture show would take over... on top of that, I forgot to disable it after the first time it happened (DUH!) and it happened twice in that presentation! Of course, the presentation went on without a problem, but I was a little bit embarrassed because I had forgotten to do that. I promise next time to turn it off ;-)

People enjoyed the demo I created, especially the one that had reusable code that Presentation2they could copy paste onto their apps for using some of the demoed Managed APIs. The one that sparked the most interest was the one where the use of the State and Notification Broker API (SNAPI) was explained and a bunch of "one liner" snippets were demoed.

The event was a complete success, and in the end there were lots of books, T-shirts, goodies, a Zune, a 22-inch monitor, software licenses and a bunch of stuff given away. Everyone got something to take home, and more important everyone was happy at the end of the event.

I thank you all 617 of you for attending the event, and especially to the ones that attended to my presentations. I hope to see you at the next event so you can tell me how you did building your first Windows Mobile applications. I would also like to thank Silvia for taking the pictures attached to this post.