Icon

First Days of AnkhSVN

Where I’ve worked we’ve been long time Visual Source Safe users. Everytime a new version of Visual Studio would come out, we’d quickly grab it from Microsoft, cross our fingers, and pray for a new version of Visual Source Safe.

It never came. Rarely did they even slap some lipstick on it.

So, we’re moving out of the slums. This week a Ubuntu 8.04 virtual machine was created (that’s a story for another day) and we installed the latest copy of SVN.

We toyed with the idea of running SVN and Apache on a Windows Server, but if you’re going to do something, you might as well do it right. Cue Mike Holmes.

Anyhow, for those few VSS users out there, so far we like AnkhSVN. I’ve got a copy of TortoiseSVN, but right not that’s just too far away from what I’m used too.

It’s nice to not have to ask someone to check in a file to make a quick chance. It’s nice to know we can FINALLY do some branching. We’re excited, but a little timid. I’ve had no luck getting our webservices into SVN, since the solution file exists seperate of the webservice itself. Right now I’m going to sit on this issue till I know a little more, but this will have to be solved.

I did run into one issue, when I moved my project from VSS to SVN and then to AnkhSVN, everytime I tried to save in Visual studio I kept getting a cannot save this file is write-protected. And it didn’t look like an IDE message, it looked like it was from Ankh. The internet was no help, nor were their forums. Finally, I wondered, maybe these files are still set read-only from their fiefdom under VSS. They were. I went through each of my local files, removed the read only flag, and I’m back in SVN bliss.

It wasn’t an easy journey with getting the SVN server up on a virtual machine, but things are looking up.

Oh, by the way! I tested both AnkhSVN and TortoiseSVN for the dreaded Empty Click Once bug, neither caused any trouble so far.

Goodbye AxWebBrowser

It wasn’t a perfect marriage, but we made it work. Your early death was documented here: IE7 Broke My AxWebBrowser!!!

I didn’t like how fat you were, between MSHTML and those two references I can never remember AxSHDocVw and SHDocVw. But you worked, and that’s all I ask.

To move over to the default WebBrowser component that comes with VS2005 I require the following things:

  1. Able to complete form items automatically.
  2. Able to click buttons on the page.
  3. Execute javascript functions on the page.
  4. Handles the new window and allows me to pop it into another web browser control.
  5. When doing #3, my ASP.NET session persists.

Ok, first we start with able to complete form items automatically.

WebBrowser1.Document.GetElementById(“txtUserName”).SetAttribute(“value”, “username”)
WebBrowser1.Document.GetElementById(“txtPassword”).SetAttribute(“value”, “password”)

CHECK!

Next, can we click a button?

WebBrowser1.Document.GetElementById(“btnLogin”).InvokeMember(“click”)

CHECK! So far much simpler than AxWebBrowser.

Now for the javascript function.

WebBrowser1.Document.InvokeScript(“myFunction”, New String() {“hello world”})

CHECK! Going great!

Here’s where we hit a snag. While WebBrowser has a NewWindow, it doesn’t give us any access to the URL. After some googling, I found someone who extended the component. Follow the directions posted by armoghan on 12/6/2007 found here.

So with that, you are given the event handler called NewWindowWithTarget, inside that event I place:

Dim frmWB As New Popup
frmWB.WebBrowser1.Navigate(e.Url)
frmWB.Show()
e.Cancel = True

And the session maintains!

And then my popups are handled! Except when I go to test it on some virtual machines, I find it does not work for Windows 2000. The author of the post did not indicate this, so I did some research. What he’s using is the NewWindow3 which was introduced with Windows XP SP2. If NewWindow3 fails, it moves on to NewWindow2 which pops up a separate IE process and loses the session. It works on IE6, IE7, or IE8 as long as you are Windows XP SP2 or higher. So that kills Windows 2000, and you can not even get IE7 for Windows 2k, so I’m screwed.

We had to make a tough call and we decided it was time to let go of Windows 2000 support. It’s been almost 9 years since it’s creation and 4 since Microsoft began to end the product life cycle. We’re able to lose the old AxWebBrowser and all the extra baggage. I hate to do it, but what choice do I have? Keep using IE6 for years?

Sigh. Check.

ClickOnce Cert Expired Issue Solved By RenewCert of May.be

Yesterday, I went to publish a new version of our clickonce application, when I was greeted by a message that Visual Studio wasn’t going to let me publish, because our certification had expired. Oh no.

We’d often talked about getting a real certification and not using the temporary one, but we never saw the real benefit, and now in hindsight, I’m really glad we did not.

So, here’s the problem:

After your first clickonce publish, Visual Studio creates a certification key file, and stores it in your project as “ProjectName_TemporaryKey.pfx”. As far as I can tell, this is used only to sign the manifest it’s never sent to the client. The only visible downside is when installing the application, it warns that it’s an unknown publisher. This temporarykey, like actual keys are good for one year from the issue date.

Once that year is up, you can’t publish anymore. If you change certs, your updates no longer work (The deployment identity does not match the subscription. ) and everyone has to reinstall the application. It seems that Microsoft acknowledges that this was by design but it was bad design, and I believe it’s much better in VS 2008.

So panic sets in, we talk about abandoning clickonce, how to get these updates to people in the mean time. We found a knowledge base article, which offers two work arounds. http://support.microsoft.com/kb/925521

The first work around is out of the question, if we do that, we get rid of clickonce for good.

The second work around, sounds confusing and I feel like we get one shot, if that doesn’t work the project is gone.

Then, I find my new favorite website: http://www.may.be/renewcert/, A wonderful person, Cliff Stanford, seems to have encountered this problem, and took Microsoft’s Workaround #2 and made it better and offered some real help.

I downloaded his version of renewcert, and tried it on one of my temporarykeys. I used the following command at first: renewcert MyProject_TemporaryKey.pfx MyProject_FiveYearKey.pfx CN=”My Company” super_dooper_password

It failed.

I got the following error:

PFXImportCertStore failed with error 0×56: The specified network password is not correct.

I didn’t see any mention of this on Cliff’s site so I started to get worried again. Decided to try again, this time, I looked at how the temporarykey was issued.

renewcert MyProject_TemporaryKey.pfx MyProject_FiveYearKey.pfx CN=”MYDOMAIN\MYUSERNAME” super_dooper_password

I had no clue what to use as password, my current domain password? The one from a year ago? I did some googling and found that when VS creates these certs, it doesn’t use a password, so I left it off:

renewcert MyProject_TemporaryKey.pfx MyProject_FiveYearKey.pfx CN=”MYDOMAIN\MYUSERNAME”

It worked! I went into VS, went to the Signing Tab in the project properties, did “Select From File”, picked my new fiveyear cert. It added it to the project for me, and extened my expiration date to 2013!

IF we would have used a real certification, I think we would have been in trouble. You would need your certification agency to issue you a new cert every year, but it would have to use the same key. This isn’t something they do often.

So, we’re going to keep on keeping on, and migrate off of ClickOnce eventually, but atleast we were bought some time. I’m suprised this issue only cost me about an hour of my time, and a little worrying.

Thank you Cliff Stanford of may.be

Storing an image in dataset, proper type.

Just a quick one, if you want to store an image to a dataset, and are creating the dataset in code, here’s the proper type:

System.Type.GetType(“System.Byte[]“)

It’s a little confusing because if you use Visual Studio’s XSD editor, it lists the type as System.Byte(). And of course System.Byte would compile but it would not behave as expected.

In the schema, the type is stored as: type=”xs:base64Binary”

Just a heads up.

 

 

IE7 – Webbrowser Control breaks select tag functionality

Found a real frustrating one today:

My application is a blend between a web app and an actual windows form application. You can either access the web app or the windows form app. A few of the more complex features are only available to you if you run the windows form app.

To share features between the two, I just embedded a web browser control on a tab, and I have it bring up the web application.

Everything has always worked great, until I upgraded a test machine to IE7. Turns out all of my dropdown boxes (select tags) inside the application’s web browser control stopped working.

So, to recap, my dropdowns work in IE7, IE6, Firefox, but they don’t work inside my application which is using IE7’s Web Browser Control.

I found the offending piece of code that I had to remove. We were doing a little style to the select boxes when you clicked on them, apparently this version of IE7 did not like it.

Offending Code:

function colorChanger(obj)
{
if (obj.style.backgroundColor == '#f00')
{
return true;
}
else
{
if (obj.style.backgroundColor == '')
{
obj.style.backgroundColor = "#eeeeee";
}
else
{
obj.style.backgroundColor=(obj.style.backgroundColor=="#ffffff"?"#eeeeee":"#ffffff");
}
}
}

I used this code like this: