Feb 8 2010

This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.Parameter name: item

Category: Desktop and ServerJoel Ivory Johnson @ 16:21

I was trying to deply a WCF service to one of my web servers the other day and ran into a problem. I kept getting the following error message:p>

This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.Parameter name: item

The problem didn't happen on my local machine but did on the web server making it a little difficult to figure out what was causing it. It happened on the server because my web server is in a shared hosting environment in which case the WCF service also needs to know the host header. To do this I navigated to <system.serviceModel> in the web.config and added the following:

<serviceHostingEnvironment>
<baseAddressPrefixFilters>    
    <add prefix=http://MyHostHeader />
</baseAddressPrefixFilters>
</serviceHostingEnvironment>

Tags:

Feb 6 2010

Windows Mobile and Color Depth

Category: MobileJoel Ivory Johnson @ 04:02

This question has come up three times in the various forums in which I participate, so I thought it would be appropriate for me to write a post about it.

Does Windows Mobile support 24-bit images?

It's been long rumored that the Windows Mobile operating system is not capable of working with images that use  24-bit pixel depth and that Microsoft should do something about this. The truth of the matter is that the Windows Mobile Operating system does support 24-bit colors. But most OEMs don't use 24-bit display hardware on their devices. A parallel to this is having a Blu-Ray player connected to a standard definition TV and concluding that because of the way images look on the screen the Blu-ray player must not support high definition.

If you've never run into the challenges that can come with using certain images with limited pixel depth then you already know why you would want more pixels per color. If you've not run into this problem before I'll explain. Let's say we are working with a monochrome (black-and-white) display. On this display we want to display an image with a gradual transition from white (on the left of the image) to black (on the right side of the image). If I allow 2 bits to be used to represent colors then there are four values that can be used to represent color intensities: 00, 01, 10, and 11. With four colors the image I described looks the following.

If I add another bit to represent colorsthen I have 8 possible values to represent color intensities: 000, 001, 010, 011, 100, 101, 110, and 111. Using 3 bits per color intensity the transition in the image looks more gradual. 

If I go with 8 bits then there are 256  color intensities. With 256 color intensities the transition in the image is smooth.

 

The key thing to take from the images above is that with less bits per image the color transitions are not as smooth. This can be rather frustrating when you go from editing an image on a system with high color depth (8-bits for red, gree, blue and possibly 8 more bits for transparency) to a system with a lower color depth (5-bits for reg, 5 or 6 bits for green, and 5 bits for  blue) can be rather frustrating at times. After all you want your images to look the same in the design environment and on the target.  For the short ter I think it's best to have the designer view image assets in 16-bit mode to ensure the look okay before handing them off to the developer. My hopes are that for the long term we will begin seeing some Windows Mobile hardware implementations that have 24-bit displays.

Tags: ,

Feb 4 2010

Windows Phone Deployment Patterns - Part 0 of n

Category: MobileJoel Ivory Johnson @ 17:29

I come from a C++ (and now C#) background. In both languages the index of the first item in a list is zero, so I like to stay consistent to that when working with other list (including blog post). In this series of blog post I'll be walking through different solutions for deployment scenarios for Windows Phones. This first solution is the "Hello World" of deployments. It will get your files copied to the programs folder and will create an icon in your start menu. I'll be ignoring all of the other considerations that one might give for a deployment such as including prerequisites, performing custom actions, or setting up the PNG icon for Windows Mobile 6.5.

Let's say that you've already written your Windows Phone program and want to get it packaged into a deployment. You first need to add a new deployment project to your solution.  Right-click on the project and select "Add New"->"Project". In your new projct dialog ind the "Setup and Deployment" category and the "Smart Device CAB Project" project type. Double-check tomake sure you'veselected the "Smart Device Cab Project" and not the "CAB Project." Type in a name for your project ad click on "OK."

 Once the project is created you can begin adding your files to it. Firt let's add te project that contains your application code to the project. right-click on your deploymnt project and select "Add"->"Project Output." In the dialog that appears make sure the name of the project that contains your codeis selected from the top drop-down. Select "Primary Output" and "Content Files" from the listbox and select "OK". Right-click on the deployment project again and select "View"->"File System." You will not be able to select where on the device's file system that your program will be installed.

The File System's view contains two folders:"Application Folder" and "Programs Folder." Hightlight and erase the "Programs Folder." We won't be using it for this walkthrough.  When you select the "Application Folder" you'll see that your program and it's resources are referenced. Right-click on the Primary Output item and select "Create Shortcut to Primary Output." A shortcut will be create with its name highlighted. Enter in a name for the shortcut.  Now you need to ensure that the shortcut will show up in the user's start menu.

In the file system editor right-click on "File System on Target Machine" and select "Add Special Folder"->"Start Menu Folder." Once the Smart Menu Folder is selected go back to the "Primary Output" foler. Click-and-drag the shortcut you made in the earlier steps into this folder.  Once you've done that if you right-click on the deployment  project nd select "Rebuild" it will produce a cab that you can use to share and install applications.

That is all that is required for a simple deployment. The next time I post on this topic I'll go through a more complex deployment scenario.

 

Tags: ,

Jan 29 2010

Testing Advanced Protection in the Windows Marketplace for Mobile

Category: MobileJoel Ivory Johnson @ 03:26
A couple of weeks ago Mike Francis posted some information on the Windows Team Blog about using advanced protection in your applications being distributed through the Windows Marketplace for Mobile. One of the things that he notes in his post is that presently there's no way for you to test the code path that gets executed if the necessary certificate is installed. I thought of a work around for this, but for it to work you need to have at least one application that has passed certification. Install your application from the Marketplace and it will install the license for you. In the application that you are still developing [temporarily] set the application ID to be the same as the application that you've already installed on the device. When you run the application it will find a valid certificate. Just remember to change it back to the applications actual ID before you send it through certification.

Tags: ,

Jan 29 2010

Using CeSetUserNotification to start a program

Category: MobileJoel Ivory Johnson @ 03:05
A few days ago I got a message from a developer that was trying to use CeRunAppAtTime to schedule an application to start up. As I had mentioned in a previous post instead of using this function one should use CeSetUserNotification since on more recent devices CeRunAppAtTime is not as reliable (not to mention it is marked as deprecated in the MSDN documentation). The developer asked me for an example of how to call the method from .Net so I put together an example for him. I am sharing the example below and plan to later update my article at CodeProject.com on Automatically Starting a Windows Mobile Program with this same code.
 public static extern IntPtr CeSetUserNotification(IntPtr hNotification, string application, SystemTime startTime,
                                                          UserNotification notification);

        [DllImport("CoreDLL.dll")]
        public static extern int FileTimeToSystemTime(ref long lpFileTime, SystemTime lpSystemTime);
        [DllImport("CoreDLL.dll")]
        public static extern int FileTimeToLocalFileTime(ref long lpFileTime, ref long lpLocalFileTime);


  [StructLayout(LayoutKind.Sequential)]
    public class UserNotification
    {
        public int ActionFlags;
        [MarshalAs(UnmanagedType.LPWStr)]
        public string DialogTitle;
        [MarshalAs(UnmanagedType.LPWStr)]
        public string DialogText;
        [MarshalAs(UnmanagedType.LPWStr)]
        public string SoundPath;
        public int MaxSoundPath;
        public IntPtr Reserved;

        public UserNotification()
        {
            DialogTitle = String.Empty;
            DialogText = String.Empty;
            SoundPath = String.Empty;
            MaxSoundPath = 0;
            Reserved = IntPtr.Zero;
            ActionFlags = 0;
        }
    }


       public static void RunAppAtTime(string applicationEvent, DateTime startTime)
        {
            long fileTimeUTC = startTime.ToFileTime();
            long fileTimeLocal = 0;
            UserNotification notification;
            notification = new UserNotification();
            notification.ActionFlags = 0;
            notification.Reserved = IntPtr.Zero;

            SystemTime systemStartTime = new SystemTime();
            FileTimeToLocalFileTime(ref fileTimeUTC, ref fileTimeLocal);
            FileTimeToSystemTime(ref fileTimeLocal, systemStartTime);
            CeSetUserNotification(IntPtr.Zero ,applicationEvent, systemStartTime, notification);
        }

Tags:

Jan 26 2010

Windows Mobile 6.5 SDK Temporarily Removed

Category: MobileJoel Ivory Johnson @ 01:01

The Windows Mobile 6.5 SDK that was made available for download last week has been removed from the web site. Having downloaded it myself I can tell you that there were some bugs in the SDK, such as only being able to target Windows Mobile 5.0 if you install the SDK on a system that already has the Windows Mobile 6.0 SDK or some weird rendering problems in the emulator. So on a positive note when the SDK is re-released others won't have to experience those problems.

Tags:

Jan 26 2010

New Certification Exam for Windows Mobile 6.5

Category: MobileJoel Ivory Johnson @ 00:56

If you're a developer with interest in Microsoft certifications then you'll be interested to know that a new exam will be available in March for Windows Mobile. Exam 70-580 covers Windows Mobile 6.5 development and looks at aspects of data management, packaging and deployment, user interface development, application optimization, and more.

Tags:

Jan 24 2010

Math without a Floating Point Unit

Category: MobileJoel Ivory Johnson @ 01:59

The everyday development that I do targets desktop processors. The processors are more than capable of meeting the computational demands and performances requirements so its rare that I ever have to think about how long it takes to execute a specific mathimatical operation. But while that's the general case it isn't always the case.

When I was finishing grad school one of my projects dealt with machine vision and automatic classification of photographs. I had an understanding of the algorithms I needed to implement and how everything was going to fit together. During development of the individual components I used small datasets that were sufficient for letting me know that the components were working as designed. It wasn't until I had brought all of the components together that I gave the system full sized images to process (around 2 megapixel) . I knew that a full sized image would take longer to process, but processing of the image took around three hours! In reasearching the cause of the slowness I found that some of the functions I was trying to execute were not nativly supported by the machine's processor and were being emulated. Some of the math operations consumed 50 to 100 times more time than the native operations. There was a time constraint on the exeution time of this program since I had to demonstrate its execution in class during a presentation. To stay within those constraings the more expensive mathimatical operations were replaced with lookup tables and the program was changed from just being multithreaded to taking full advantage of multiprocessing.

In the past few weeks I was reminded of the experience after getting a couple of e-mails from other developers that were trying to figure out why their programs were having such poor performance. Both developers were creating programs that performed graphical processing and both were targetting Windows Mobile devices (which use ARMS processors). ARMS processors are available with a broad range of performance characteristics. On the lower end the processors only support integer operations, have no divide instruction, and typically run around 200 MHz. On the upper end the processors may have hardware implementation for floating point operations (including a divide instruction), built in 3D graphic accelerators, and run at up to 1 GHz. Both of the developers were testing their programs on devices that had no native floating point support and no divide instruction. So these operations were being emulated. That information alone was enough to answer their questions. But I decided to do a few measurements.

I dug up every ARMs based device running a Microsoft OS that I could find. In my possession I have several Windows Mobile devices from PocketPC 2002 devices to a newly released device that will soon have Widnows Mobile 6.5. The Microsoft Zune is also ARMS based. So I included it in my test. I've also got remote access to a few newly released devices. For the test I had each device perform a million additions, subtractions, multiplications, and divisions for both integer numbers and double-precision floating point numbers. For the Windows Mobile devices I did this using native (C-language) programs since the .Net Compact framework does not support floating point operations. For the Zunes I used .Net through the XNA framework. The Zune version of the .Net framework supports floating point operations. Because of the broad range of clock frequencies that these devices used for each device I used the time taken to perform a million additions as a base measurement. My findings were fairly consistent. In general the devices that had no floating point support took about 30-times longer to perform a division on a double-precision number than the integer addition. Devices that had floating point support took about 2-time longer to perform a double-precision division than addition.

The algorithms that both developers were implementing made heavy use of floating point operations. There had been some expectations made about the performance of the programs when run on a mobile device that had been transfered from experience with desktops. Desktop processors have a more complete set of hardware implemented math operations than mobile processors. Both developers also had the same device which had no floating point support. So it comes as no surprise why the algorithms were running so slow. So what could they do about it? There's no universally satisfying substitute for a capable hardware so the exact solution is going to depend on what one is trying to accomplish. For one developer an acceptable solution was to use a different algorithm that produced acceptable results and had a much lower computational demand. For the other developer compromises on the result were not as acceptable so the hardware requirements for his software were revised so that they identified the needed hardware.

The experience from school and the experience of the two developers underscore the importance of making sure that solution's hardware and implementation are in sync with each other.

Tags:

Jan 23 2010

Windows Mobile 6.5 SDK

Category: MobileJoel Ivory Johnson @ 13:56

The Windows Mobile 6.5 SDK is available. I downloaded and installed it and can't say I've had a chance to dig into it. After installing it my system only allowed Windows Mobile 5 targets. I had to uninstall the Windows Mobile 6 SDK and do a repair install of WM6.5  to fix that. So far the only thing that stands out is there is a new project type for making widgets.

Tags:

Jan 21 2010

New Development Certificate for Windows Mobile

Category: MobileJoel Ivory Johnson @ 11:44

A couple of weeks ago I posted a solution for the expired development certificate for Windows Mobile. I almost forgot to mention that the Windows Mobile Development Team posted new development certificates last week. You can download them from their blog entry about the certificates.

Tags:

Jan 20 2010

Passed Application Certification on WiMo Marketplace

Category: MobileJoel Ivory Johnson @ 15:25

Certification Passed

Not long ago I mentioned publishing a very simple application to both the Windows Mobile Marketplace for Mobile and the Samsung App Store to see how the process went and make the code available for any one that was interested. I got back good news from the Marketplace today. My application passed certification. This was actually my second attempt to pass certification. The first time it failed certification because the application didn't respond well to forceful shutdown (Something described in the guidelines but I had forgotten about). For this second attempt at certification the entire time in queue was about three days, not bad. I've not made the application available for download and am now submitting a simple update to the application to see how that process goes. I'll detail more of my experiences after the update receives certification.

Tags: ,

Jan 17 2010

Browse the Android Marketplace from the Web

Category: MobileJoel Ivory Johnson @ 15:11

I found out about this site through the CodeProject article that I mentioned in my previous post.  This is a third party site that allows you to browse what is in the Android Market. The uninitiated may wonder why one would use a third party site to browse the Android marketplace. The reason is that the only official channel for seeing what is in it is to browse the Marketplace through your phone. But doing so will only let you see what applications are available to your device and not everything the Marketplace has to offer. If you are interested in browsing go to http://www.androidzoom.com/

Tags:

Jan 17 2010

Marketplace Comparison article on Code Project

Category: MobileJoel Ivory Johnson @ 15:04

If you've ever been curious about the differences in the online application stores for the iPhone, Windows Mobile, and Android there's a rather lengthy comparison available over at CodeProject.com. Among other things the article covers the registration costs for each of the stores, what it takes to get started with development, and a breif comparison of the platforms.

http://www.codeproject.com/KB/mobile/wm_iphone_android_market.aspx

Tags: , ,

Jan 13 2010

App Versions and the Windows Marketplace for Mobile

Category: MobileJoel Ivory Johnson @ 13:24

I've come across a few questions in the forums about version numbers in the Marketplace. Having answered questions around this several times I thought it was time to do a blog posting. 

Some users have installed applications from the Windows Marketplace for Mobile and noticed that when they check on the version number for the application (usually through the menu sequence Help->About) they see a version number that doesn't match the version number as listed in the Marketplace. Some users have thought this was an indication that the wrong version of the application had been sent to them.

The confustion comes from there many times being no relationship between the version number listed in help->about and the version number reported by the Marketplace. The version number reported by the application uses the format <major version>.<minor version>.<build>.<revision> while the marketplace uses <major version>.<minor version>. As a software developer I could publish an application and have it's version number as 1.0.0.0 in help-> about and 1.0 in the Marketplace. But if I make a minor update to it and update help->about to display 1.0.1.0 it mail display 1.1 in the marketplace. For my next update it may be 1.0.1.1 but 1.2 in the marketplace. See how these numbers are begining to diverge?

One of the applications in question is the Bing application. Bing comes preinstalled on many devices and there have been users that have thought that that version preinstalled on their device was preventing the installation on the lates version. As a test I took a device that had no version of Bing on it and connected to the Marketplace. When I found Bing in the Marketplace it shows that it is on version 6.

I downloaded and installed the version that the Marketplace reports to be version 6.0. Going through the menu sequence Help->About we see that the Marketplace 6.0 labeling is for verxion xxx of this app.

Tags:

Jan 11 2010

Auto Updating Version Text

Category: Joel Ivory Johnson @ 15:11

I was making an application with an About dialog that shows the version number for the app. Rather than add the version number as static text I made use of reflection to extract the version number from the assembly. If you are interested in doing the same in your application you can use the following code to get the version number text.

Regex versionRegex = new Regex("Version=(?\\d\\.\\d\\.\\d\\.\\d)");

String GetVersion()
{
    string fullName = (this.GetType().Assembly.FullName).ToString();
    Match m = versionRegex.Match(fullName);
    if(m.Success)
    {
        return String.Format("{0}", m.Groups["ver"].Value);
    }
    else
    {
        return "";
    }
}

Tags: