ClickOnce Team Blog

Posted by Jeffrey Vanneste at 01:52 PM on December 12, 2005

Category: Development

The ClickOnce Team have started a blog which should be a useful source of information. Two useful links to check out: ClickOnce FAQ and the Official ClickOnce Forum.

Compile .NET 1.1 applications VS2005

Posted by Jeffrey Vanneste at 07:30 PM on November 07, 2005

Category: Development

I was under the impression it was not possible to compile .NET 1.1 apps in VS2005 but apparently I am wrong. I haven't tried this out yet but pending it actually works this will be a great start to switching to VS2005.

Regular Expressions

Posted by Jeffrey Vanneste at 09:06 PM on November 02, 2005

Category: Development , Useful Tools

A fellow coworker sent around this awesome Regular Expression link the other day that I thought I should spread as well:


http://www.regular-expressions.info/tutorial.html

I use regular expressions as often as the interval it takes me to forget most of the useful regex stuff I learn. Everytime a situation comes up that I should use regex I have to try and remember everything I knew about regex. Well, this tutorial explains regular expressions in such a way that I'm hoping it will stick with me longer this time.

To go along with this tutorial I couldn't very well not post an awesome regular expression utility. My personal favorite is The Regulator. It links in with the Regular Expression Library so you already have access to tons of regex. If you haven't heard of it, it's worth checking out. Another tool that I sometimes go back to using is Regex Designer which is made specifically for .NET applications. It has an option to generate some code stubs for you which saves some time.

ClickOnce Deployment on a Linux web server

Posted by Jeffrey Vanneste at 12:48 PM on October 29, 2005

Category: Development

My web host runs on Linux so I wanted to make sure that I would be able to use ClickOnce without having to find a new host. Well, it turns out that it was very easy to get this to work (though some steps become manual). Here are the steps I followed:

  • In the property publish settings you will need to set the Installation URL to the URL you will eventually put the ClickOnce application on. In my case, http://www.bunnyhug.net/ClickOnceTest/. The publishing location can be whatever you want to test with. I used my local IIS.
  • If you want your application to check for updates you will need to click the Updates button and set the Update Location to the URL you want to check for updates with. Once again in my case it was http://www.bunnyhug.net/ClickOnceTest/.
  • So now build and publish your application to your local IIS or whatever you selected for the Publishing Location. Upload the resulting files to your web server so they will be in the proper folder to match the Installation and Update URL.
  • One last thing to do, since I doubt your web host have the proper MIME types set you will need to add the following to a .htaccess file in the folder you uploaded your published files (or use this example.htaccess file):
    AddType application/x-ms-application .application
    AddType application/x-ms-application .manifest
    AddType application/octet-stream .deploy

This allowed me to hit http://www.bunnyhug.net/ClickOnceTest/ and install my Click Once Test application. It should look something like this in IE:

When I tried in firefox I got a bit different result:

For firefox I had to click the Install button which downloaded the Setup.exe file. After running this file manually it installed the application just like clicking the Install button in IE did.

So that should be all to get ClickOnce applications deploying from a non-IIS server. The downside is you will have to upload your files manually after you publish locally each time. If you have FTP access to your host you can make this a bit easier by setting up the Publishing Location to the FTP location that matches your Installation and Update URL.

Compact Framework Version 2.0 Download

Posted by Jeffrey Vanneste at 12:45 PM on October 29, 2005

Category: Development , Pocket PC

Overview
The Microsoft® .NET Compact Framework 2.0 Redistributable includes everything you need to run applications built for both NET Compact Framework v1 and v2, including the Common Language Runtime and the .NET Compact Framework class library.

Download

Uninstalling Beta/RC VS2005

Posted by Jeffrey Vanneste at 10:19 PM on October 27, 2005

Category: Development

Aaron Stebner has an excellent post on the different options for uninstalling your beta or RC version of Visual Studio 2005. I'll stick with my format and auto-install of windows to avoid any uninstall issues.

And yes, if you haven't heard, VS2005 and SQL Server 2005 are out for MSDN subscribers. The redistributables for .NET 2.0 can be found here:

Microsoft .NET Framework Version 2.0 Redistributable Package (x86)
Microsoft .NET Framework Version 2.0 Redistributable Package (x64)

And the SDK links:

.NET Framework 2.0 Software Development Kit (SDK) (x86)
.NET Framework 2.0 Software Development Kit (SDK) (x64)

Update: I found out about this link after this post, http://msdn.microsoft.com/netframework/downloads/updates/default.aspx has all the downloads for pretty much anything .NET related on Microsoft's site.

Executing commands on a remote machine

Posted by Jeffrey Vanneste at 11:32 AM on August 04, 2005

Category: Development

I've been working on some build improvements, one of which is eliminating the need to copy all our deployment files to each of the application servers after they have been put into a staging folder by NANT. Since NANT copies all binaries from a build folder to a staging folder and then when we want to deploy we have to copy all the files again from the staging folder to the application server it was becoming quite time consuming. If we create a single file installation from the build folder we can eliminate the need to copy to the staging folder and then we only need to copy a single file to the application server and execute it there.

What I wanted to be able to do from the build machine was tell another machine to upgrade to the new version without having to connect to any of the application servers. The problem here is remote execution of any commands on the application servers, so I started my research. I searched in google and found various programs that offered remote execution but some required installing software on the application server (not desired) or cost a lot of money. I first tried RemoteExec (about $120USD/license) which seemed to be the one that showed up in most of my searches. When I tested it out locally it worked great but as soon as I tried to execute programs on other computers on the network it was very unreliable. One time it would load up the program and the next time nothing would happen. With that and the lack of command line support (or at least as far as I could tell) I decided it was time to find something else.

In the end I found a wonderful program by sysinternals called PsExec (freeware too) that did everything that I wanted (and it actually worked). Nothing needs to be installed on the target machine at all. The only requirements are you need to have port 139 and 445 open on the target machine and you need administrator access. Since I haven’t decided for sure which installation package I will be using to bundle our deployment files into I wanted to make sure that a couple of them worked correctly. My first test was using MSI files. I was unable to use the copy file option from PsExec (-c) with MSI files so in the end I had to put the MSI file on a shared folder on the network. Since I was accessing the network I needed to specify the user for PsExec so I would have the proper network credentials. Here is how the command should look:

psexec \\TargetMachineName -u DomainName\UserName -p Password 
msiexec /i "\\SourceComputerName\SharedDrive\Setup.msi" /qn

When I tested a NSIS setup file it worked much easier as the copy file option worked fine.

psexec \\TargetMachineName -c NsisSetup.exe /S

Another nifty thing I discovered with PsExec was the ability to specify multiple computers to execute the command on. There are 3 different ways you can do this. "psexec \\* -c NsisSetup.exe /S" would execute on every machine in the domain. "psexec \\Machine1,Machine2 -c NsisSetup.exe /S" would execute on Machine1 and Machine2. "psexec @ComputerList.txt /S" would execute on every machine listed in the ComputerList.txt file.

I found a good article on Windows IT Pro which gave a good description of how PsExec works:
"PsExec starts an executable on a remote system and controls the input and output streams of the executable's process so that you can interact with the executable from the local system. PsExec does so by extracting from its executable image an embedded Windows service named Psexesvc and copying it to the Admin$ share of the remote system. PsExec then uses the Windows Service Control Manager API, which has a remote interface, to start the Psexesvc service on the remote system.

The Psexesvc service creates a named pipe, psexecsvc, to which PsExec connects and sends commands that tell the service on the remote system which executable to launch and which options you've specified. If you specify the -d (don't wait) switch, the service exits after starting the executable; otherwise, the service waits for the executable to terminate, then sends the exit code back to PsExec for it to print on the local console."

Some useful links:

Developing Compact Framework version 1 applications with beta2

Posted by Jeffrey Vanneste at 09:57 PM on April 18, 2005

Category: Development

Just noticed this tonight. Not only can you create 2.0b2 compact framework applications with Visual Studio 2005 beta 2 but you can also create 1.0 SP3 applications as well.

cfnetVersion1AndVersion2.jpg

ClickOnce Deployment in Beta2

Posted by Jeffrey Vanneste at 09:52 PM on April 18, 2005

Category: Development

Wow! ClickOnce is very cool. If you haven't tried a ClickOnce application spend a couple minutes and give it a try. I was going to write an article on getting started with it but I found one already written which was close enough to work with beta2.

Visual Studio 2005 Beta2

Posted by Jeffrey Vanneste at 03:17 PM on April 17, 2005

Category: Development

It's finally out! I had a chance to play with it for a few hours today. The first thing I tested was trying one of my Pocket PC games in the new Device Emulator (version 8). Finally I'm able to test my games that make GAPI calls. Previously I had to debug all my stuff on my Ipaq which was a pain to do not to mention it doesn't have Windows Mobile 2003SE.

After migrating one of my Pocket PC games I played with ASP.NET 2.0 a bit as I use ASP.NET at work all the time. The beta2 .NET framework comes with a great sample library explaining all the features of ASP.NET 2.0 and whats added/different from the 1.0. This should keep me busy for awhile.

With previous versions of VS2005 I had random crashes every now and then but so far this one has been a lot more stable. Anyways, back to playing.

del.icio.us Updater and Importer

Posted by Jeffrey Vanneste at 11:19 AM on December 10, 2004

Category: Development

I just discovered del.icio.us earlier this week. del.icio.us is a "Social Bookmarking" site where all of your bookmarks are public. The nifty thing about this is that you can see everyone else who bookmarked a page and then see what other pages they bookmarked in the same category. del.icio.us lets you assign tags to bookmarks (like how gmail uses labels) so it makes it really easy to search for bookmarks.

Since del.icio.us keeps all your bookmarks online it solved my problem about sharing bookmarks from work/home/parent's house but I wanted to have the bookmarks show up in my quick launch folder. There already is a great plugin for firefox that lets you do this called foxylicious. However, I don't use firefox that much as I still use maxthon as my main browser. I was unable to find the "live bookmarks" feature for maxthon so I figured I would write a simple application to download the del.icio.us bookmarks and put them in my favorites folder so they would show up in my quick launch. So I wrote a program called BUD (Bunnyhug Updater Del.icio.us) which does exactly what I want.

My final problem was a way to import bookmarks into del.icio.us. I was able to find a perl script but that wasn't my cup of tea. So I wrote a simple importer for BUD that reads in your favorites folder and lets you import one bookmark at a time or all the ones you have checked into tags that you specify.

And since I'm talking about del.icio.us here is a script to let you right click on a page to add the URL to your bookmarks on del.icio.us.
Right-click to add URL to del.icio.us in IE
Right-click to add URL to del.icio.us in IE (With more features)

Focus() not working?

Posted by Jeffrey Vanneste at 03:33 PM on November 01, 2004

Category: Development

We had this strange problem at work today where we would give focus to a TextBox by calling the Focus() method and for some reason the TextBox got focus but yet the cursor was still not on the TextBox. How do we know it had focus? Well, we would press tab and the next button in the tab order got focus. Pressing shift+tab hid the focus again but pressing shift+tab one more time and we would end up on the control before the TextBox.
If we switched to any other window and came back to the form or minimized and restored the form the focus would all work fine. Our solution, instead of calling the Focus() method on the TextBox we simulated a mouse click on the TextBox:

SendMessage(this.textBox.Handle, Win32.WM_LBUTTONDOWN, 0, 0);
SendMessage(this.textBox.Handle, Win32.WM_LBUTTONUP, 0, 0);

My other discovery today was that I don't need to use Win32 imports to send Shift+Tab keyboard strokes like this:

byte[] pbKeyState = new byte[256];
Win32.GetKeyboardState(pbKeyState);
pbKeyState[(int)Win32.VK.SHIFT] |= 0x80;
Win32.SetKeyboardState(pbKeyState);
Win32.PostMessage( this.Handle, Win32.WM_KEYDOWN, (System.UInt32)Win32.VK.TAB, 0); 
Win32.PostMessage( this.Handle, Win32.WM_KEYUP, (System.UInt32)Win32.VK.TAB, 0); 
System.Windows.Forms.Application.DoEvents();
Win32.GetKeyboardState(pbKeyState);
pbKeyState[(int)Win32.VK.SHIFT] ^= 0x80;
Win32.SetKeyboardState(pbKeyState);

It's so much easier to just do it like this:

System.Windows.Forms.SendKeys.Send("+{TAB}");

Silly me :) And one final note, pinvoke.net is an absolutely fabulous site for finding different Win32 structures and imports for use with .NET.

Visual Studio 2005 Bootstrapper

Posted by Jeffrey Vanneste at 12:39 PM on September 14, 2004

Category: Development

I'm so happy about the new bootstrapper in visual studio 2005. I just started reading the MSDN magazine October 2004 issue and it has an article on the new bootstrapper. I write most of the installation/deployment scripts that we use at work for the projects I work on. We originally started off using MSI files but I gave Nullsoft Scriptable Install System a try and was really impressed with how easy it was to use. I started using NSIS to release patches for the product I was working on and it worked very slick. When we refactored pretty much our entire product I had the opportunity to redo the installation packages that I had previously wrote.
The new bootstrapper makes it very easy to include prerequisites with the deployment of your application. You could make a CD with .NET 2.0, DirectX, Windows Media Player, and SQL Server. The article also mentions you can have it require any third party applications so it's not limited to just Microsoft ones. Anyways, if you deal with deploying products check out the article linked below.

Bootstrapper: Use the Visual Studio 2005 Bootstrapper to Kick-Start Your Installation -- MSDN Magazine, October 2004

C# Coding Standards

Posted by Jeffrey Vanneste at 09:52 AM on September 14, 2004

Category: Development

It's really too bad there wasn't a nice coding standard like this written up when we started on C# at work. Looks pretty good from what I checked out, I think I'll start following these for my own projects.

Lance Hunt's C# Coding Standards v1.13

Work Space Quality

Posted by Jeffrey Vanneste at 10:54 PM on September 06, 2004

Category: Development

Joel On Software posted today about an article on work space quality. It's mainly just references to other articles and studies written about it but I found most of the links from the article quite interesting.

Article Link

.NET 1.1 SP1 out

Posted by Jeffrey Vanneste at 06:55 PM on August 30, 2004

Category: Development

Microsoft .NET 1.1 SP1 is out. Here is a list of all the changes/fixes that it contains.

Download details: .NET Framework 1.1 Service Pack 1

Visual Studio 2005 Express Beta Downloads

Posted by Jeffrey Vanneste at 01:56 PM on August 26, 2004

Category: Development

Found this link today to download all the VS2005 express beta applications.

Code Project Article #1

Posted by Jeffrey Vanneste at 09:47 AM on April 26, 2004

Category: Development

My first code project article. They are having a contest right now for .NET Compact Framework articles. They are giving away 5 Ipaq 4150's so I'm hoping on winning the "random entrant" category.

Transparency in Bitmaps

Posted by Jeffrey Vanneste at 09:53 PM on February 25, 2004

Category: Development

I've started working on my new game although I'm not quite sure what it will be in the end. I'm pretty sure it will be a puzzle game on a board made of hexagons (I have a couple hexagon-ish games in mind) so I've just been working on drawing hexagons so far. I originally tried just using DrawPolygon to draw the polygons but they looked so boring so I figured I'll make up some nice looking hexagon bitmap and just draw that. Well, I haven't ever had to draw a bitmap with transparency so I looked into that tonight. Apparently the MakeTransparent method isn't available in the Compact Framework so I had to see if there was another way to do it. My last resort was to loop through all the pixels of the bitmap and turn the colors that I wanted to be transparent manually but thankfully I don't have to do that. Anyways, using the ImageAttributes class it was quite easy to specify which color to be transparent. So here it is:

Graphics g = e.Graphics;
Bitmap hexagon = new Bitmap(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("TransparencyTest.hex.bmp"));
System.Drawing.Imaging.ImageAttributes ia = new System.Drawing.Imaging.ImageAttributes();
Color transparentColor = hexagon.GetPixel(0,0);
ia.SetColorKey(transparentColor, transparentColor);

// draw hexagon with transparent background
g.DrawImage(hexagon, new Rectangle(50, 25, hexagon.Width, hexagon.Height), 0, 0, hexagon.Width, hexagon.Height, GraphicsUnit.Pixel, ia);

// draw hexagon without transparent background
g.DrawImage(hexagon, 50, 100);

This draws the following bitmaps on the screen:

notTransparent.png

transparent.png

That's pretty much it. My sample project can be dowloaded here. Later I'll post some code on drawing the hexagon so they are connected properly. I found the secrect is multiples of 4. Till then, enjoy.

RCS to CVS

Posted by Jeffrey Vanneste at 09:30 PM on February 09, 2004

Category: Development

Well tonight I'm making the change from Component Software RCS to a linux CVS server and using Tortoise CVS for the front end. Originally I used CS-RCS at work and they had a free single user version so I used that one at home. Well, I'm pretty much fed up with the CS-RCS file explorer and the shell extensions (not to mention I was just using the RCS capabilities of it) so I decided I would install the CVS server on my mandrake linux box here and try out Tortoise CVS as recommended to by a friend. So that's my evening, moving all my source code over to the CVS server. Fun fun.

Ipaq 4150

Posted by Jeffrey Vanneste at 11:45 PM on January 29, 2004

Category: Development

Oh my, I finally got my new pocket pc! I've only had it for a day but I'm very impressed with it so far. I let my friend borrow it for a bit and he put a big scratch right in the middle of the screen (thankfully I had put on a screen protector already) so I'm happy about the screen protector but sad about the scratch. No dead pixels on this pocket pc either which is obviously good. However, I do have the problem with the backlight staying on when pressing the power button to turn off the pocket pc. Apparently something to do with active sync according to Brighthand Forums. Anyways, hopefully I can start developing for it again. Maybe another puzzle game or maybe I'll look at doing some network-ish stuff. I also want to fix my old 2d graph control up so it can actually be used easily by other people. Anyways, I think that's it for me tonight. I'm off to watch some Hunter X Hunter before heading to bed. Hopefully it doesn't break -50'C tomorrow.