Archive for July, 2009

Local Deployment of a ClickOnce application

July 20, 2009
You can deploy a ClickOnce application to localhost, i.e. your local web server on your own machine. After deploying your application to your local web server, you can install the application on your machine, on another machine in your local network, or in a VM. This is a great way to make sure all of the files required to run your application are included and/or the prerequisites work correctly.

It can take me several minutes to deploy the GoldMail Composer application to our development web server that provides access from the internet, but deploying it locally only takes a few seconds, so this method saves me a lot of time when I’m repeatedly testing a deployment.

You need to have IIS installed and you need to know the name of your Computer. This GoldMail gives a general idea on how to accomplish those two tasks, and then shows how to set your options to deploy your ClickOnce application locally and test it.

View in browser

ClickOnce Desktop Shortcut using VB

July 19, 2009
This is a follow-up post to the article How to Create a Desktop Shortcut for a ClickOnce Application, providing the VB version of the code, as requested by one of the readers of this blog.

The implementation is slightly different in VB than it is in C#. In C#, you just add the code to the Program.cs and run it prior to the first form being displayed.

In VB, the best place to call this is in the Application Startup event. This video will show you exactly how to do that.

This download contains the sample code in VB (VS2008) as well as a Word document with the same information as the video.

[Edit 7/7/2011 Move zip file to Azure blob storage]

[Edit 3/8/2015 Move to different Azure blob storage account]


July 9, 2009

I’ve joined twitter with the username RobinDotNet. If you want to chat me up, you can join twitter and ping me!

I’ve been a bit incommunicado for a while, because I’ve been back to working major hours. I’m still answering questions in the MSDN ClickOnce and Setup & Deployment forums, though. It’s important to me to keep up with that, because very few people other than MSFT answer ClickOnce questions there, and I seem to be able to help people. When I’ve needed help, people in the C# and WinForms forums, etc., have helped me, so it’s my way of giving back to the community.

Why have I been working so much? I’m working on streamlining and standardizing the software in the backend at GoldMail. You know how you take over a job from someone, inherit a bunch of code, get no turnover, and have to figure it out? Welcome to my world. But I always love a challenge. The problem was that a lot of this code was the kind of thing that you write when you’re in a hurry and you’re just trying to get it to work, and you never have time to go back and clean it up. You know what I mean; we’ve all done it. (Actually, I’ve never done it, I just work more hours. 😉 ) The code worked, but it wasn’t optimal, and some was overcomplicated. Plus, some of it was still in .Net 1.1.

Also, someone had taken all of the private webservices and tucked them into one Visual Studio solution, and same for the public webservices. The problem with that is if you want to branch one of the private webservices for version 1.1 and another for 1.1 later, it makes it very difficult.

I split out all of the webservice projects into separate solutions and rebuilt all of the web references and made sure everything targeted .Net 2.0. So now we can build and deploy them separately. This makes it really clear what is being released in each GoldMail Release.

The next thing was our conversion service, which takes the GoldMail assets that are uploaded by our desktop product (the Composer) and turns them into a playable GoldMail. This is a Windows Service, and we had not modified it in well over a year. The one that we have in production works, but once in a great while it has a problem unzipping the files.

The first step for this was to get it to build as a .Net 2.0 project, and figure out how to deploy it. It had a lot of moving parts, and was extremely complicated.

After I finished, we built everything and put it on staging and gave it a good drubbing, and then moved it to production. This gave us a baseline to work with. I was very excited about this, because it was a huge release, and nobody noticed it. This means that it worked.

Our next release, currently scheduled for the end of this month, is what we call our “Facebook release”. I don’t want to give specifics, but I will say we’ve made things more elegant for our customers who post GoldMails on Facebook. This release required updates to the conversion service. Did I mention the code was incredibly overcomplicated? Updating it seemed like adding more gargoyles to the Notre Dame Cathedral, so I decided to rewrite it.

It took me 2 days. I removed all of the unneeded code (someone was planning for expansion that never happened), and added a substantial amount of logging, including showing the GoldMail ID in each logged entry so you can easily track the progress of a GoldMail conversion. I added the features we needed for Facebook, added double-checking on the files after they were unzipped, and addressed a couple of other bugs as well. And I added a whole lot of comments. (Someone I used to work with would sneer and say, “She puts comments in the code”, as if that’s a bad thing.)

I think the “files missing after unzip” problem was caused because the old program unzipped the files, then set the zip archive to null and called the Garbage Collector. I think it basically removed it before the files were flushed to disk. The only time you really should ever need to call the Garbage Collector is if you are using something that is unmanaged, like GDI+ or audio or something like that.

I reduced the code base from over 5,000 lines of code to about 600. From 20+ classes to 3. Yes, you read that right. AND I added logging and comments. I reduced the complexity of the build and reworked the process to remove a CLR trigger from our database.

CLR triggers are very cool, but that’s not a good reason to use them. This is a trigger you can write in C# or VB and have SQLServer run; they are not performant, and you should pretty much only use them if they are your only choice. I removed this trigger and backed the business logic up into the prior step.

The conversion service rewrite, along with all of the other backend changes we needed for the Facebook release, have kept me very busy. After working 18 hours on Monday and 12 on Tuesday, I’m happy to report all of the backend and client application work items have been completed, and we deployed it all to staging for QA to test today (Wednesday). It is currently scheduled to be released some time before the end of July.

So what comes next? I’m going to structure the backend to handle what I call “Replace-A-GoldMail”, and then wait for the Product Manager to figure out how best to take advantage of it. I think it would be awesome if you could replace the content of a GoldMail and not have to change the URL. For example, you could do monthly status GoldMails and embed it, and it would play the newest one.

Things are calmer at work now that I have a baseline on the backend that is pretty clean, and I’ll be able to stop working weekends again (I’m making no promises about the length of my days though!) I have some great ideas for articles for my blog.

How to deploy a SQLServer (Express or CE) database, and handle updates? How to add files to your deployment? How to deploy 3rd party dll’s without pushing them as prerequisites? How to deploy SQLCE without pushing it as a prerequisite? How to deploy to localhost to test your deployment? These are questions I see over and over again in the MSDN ClickOnce forum.

Other ideas: How to create an Outlook 2007 Add-In that customizes the Office Ribbon and deploy it using ClickOnce? (I wrote one for GoldMail on my own time, just for fun — it’s very cute.) How to write a windows service and have it run multiple tasks simultaneously and asynchronously using a thread pool and callbacks? How to install the same windows service? How to add and remove items from an MSMQ? How to run an MSMQ on your own machine?

I also have an idea about writing a PowerPoint Add-In for GoldMail. My friend Beth Massi, who works at MSFT, grins every time I mention that. Apparently PowerPoint is the least-documented object model in Microsoft Office. Heck, why start with something easy?

(Note: If you’re working on VSTO applications, check out the new VSTO book by Eric Carter and Eric Lippert. It’s awesome, and covers a LOT of information.)

So that’s what’s coming up. I’m looking forward to it, and hope you are too.