Restart

After an almost 10 year hiatus this little blog is being restarted with a new theme and hopefully new articles on their way. I’m getting deeper into web development areas this year and some of the new focus is on the Umbraco CMS and Aurelia Javascript framework.

I’m also planning on using the blog as a journal of some of my work and research so expect a few posts that are more of the short note, (professional) diary entry format.

restart

How to create a SSL certificate with custom domain name for use in IIS7 web sites

IIS7 supports creating self-signed certificates. This is done from the root web server folder, under the "Server Certificates" icon. The feature works well as long as you are using your computer’s name as the domain name of the web site, e.g. http://mycomputer/.

A problem arises if you want to use a different domain name for your development and testing purposes. I have created additional local DNS mappings in the C:\Windows\System32\Drivers\etc\hosts file, such as "127.0.0.1 dev.langlo.no". When I try to go to a page using this domain and the HTTPS protocol (e.g. https://dev.langlo.no/login.aspx), I get a warning that the certificate is for a different domain (the local computer name domain). It’s possible to get past the warning and use the SSL tunnel on the site, but if you are running a web application under partial trust (for instance a WPF XBAP), then this warning causes your application to refuse to accept the SSL connection.

The solution to this problem is to create a self-signed certificate that is issued to your specific domain (e.g. dev.langlo.no). Unfortunately I don’t know how to do this from within the IIS Manager UI.

After many hours of research today I finally found out how to this. Here’s the solution

Open a Visual Studio command prompt (has yellow font color on my machine) and run the following two commands (note, you have to "Run As Administrator"):

makecert.exe -n "CN=Koda Root CA,O=Koda Software,OU=R&D,L=Salt Lake City,S=UT,C=US" -pe -ss Root -sr LocalMachine -sky exchange -m 96 -a sha1 -len 2048 -r

makecert.exe -n "CN=dev.langlo.no" -pe -ss My -sr LocalMachine -sky exchange -m 96 -in "Koda Root CA" -is Root -ir LocalMachine -a sha1 -eku 1.3.6.1.5.5.7.3.1

You want of course to replace my identifiers with yours:

"Koda Root CA" – this is the name of your Root Certificate Authority

"O=Koda Software,OU=R&D,L=Salt Lake City,S=UT,C=US" – company data, optional

"dev.langlo.no" – this the domain you need the SSL protocol to run within

Just for completeness sake, I’m running Windows Vista Ultimate, SP1 and Visual Studio 2008 Professional.

Hope this helps!

WPF, Silverlight, Mix’08

Technorati Tags: ,

Not much has happened here on this blog since middle of last year. I’ve been busy developing a suite of business software for Langlo AS using WPF (and a bunch of underlying technologies), and thus I haven’t focused as much on blogging.

This might change, though, since I’m going to Microsoft’s Mix’08 Conference this coming week (March 4-7, 2008) in Las Vegas with my colleague at Koda Software, Jason Berg. I’m really excited about Silverlight 2 and that the first public beta of it (hopefully) will be released at the conference. As far as I can tell, Silverlight 2 is very close to WPF in its feature set, and that should give those of us who have been working with WPF for a while (2.5 years in my case) a great starting point for the next wave of rich internet applications.

I hope to find some time to blog from the conference and maybe also post some photos. Check back in the coming days!

Can’t connect to local machine after latest Windows security patch/update

After performing a fairly large patch update from MS yesterday, I noticed a problem with connecting to websites running on my computer (TorT60p). To begin with I thought it was a problem with IIS7, but I later found that I was not able to ping TorT60p at all.

After much research I finally came to the conclusion that the problem is related to "Microsoft Security Bulletin MS07-038 – Moderate" – "Vulnerability in Windows Vista Firewall Could Allow Information Disclosure (935807)" Pasted from <http://www.microsoft.com/technet/security/Bulletin/ms07-038.mspx>

I haven’t found anyone else reporting the same problem, but I was able to work around it by following the instructions in the bulletin on how to disable Teredo, quote:

Disable Teredo

You can help protect against this vulnerability by disabling the Teredo transport mechanisum. This prevents Teredo from being used as a transport or mechanism to traverse the NAT. To do this, follow these steps:

1.

Right-click on the Run menu item and choose Run as elevated.

2.

In the Run box, type Netsh int ter set st disable

Pasted from <http://www.microsoft.com/technet/security/Bulletin/ms07-038.mspx>

After doing this I was immediately able to ping TorT60p again.

Background information: I’m running Windows Vista Ultimate and I’m using IIS7 on it. To test a WPF browser application we’re working on I need to use my local machine name as the web site domain instead of "localhost". This is how I discovered the problem.

Using Windows Vista, IIS 7.0 (IIS7), and Visual Studio 2005 Professional for ASP.NET development.

Every developer’s dream is to have a computer and development environment that just works, where you can focus on getting your job done without having to deal with hardware and software configurations and everything that comes with that. You would much rather troubleshoot your own programs (for the joy of your customers) than having to debug Windows, Visual Studio, IIS, etc.

In the spirit of the statement above, I have posted an article on Koda Software’s web site that takes you through the initial required steps when you are about to set up your development environment on Windows Vista for ASP.NET development and debugging.

The article addresses IIS7 configuration issues, how to switch Visual Studio to use IIS7, and how to enable debugging of ASP.NET web sites. The document is available in the following formats:

Enjoy!

I am staying here…

I have been planning to incorporate my blog into the www.kodasoftware.com web site, but the way things are looking right now I have decided to keep my blog here for the time being.

The idea was to have a single cohesive web site for Koda Software and my own professional writing, nicely integrated using a blog-like look and feel.

The problem, of course, is that setting up a blog site with the appropriate look and feel, and having it match the rest of your web site, just takes too much time when you have customer projects to complete at the same time.

Until I again have some extra time to spare, I will continue to write here, while at the same time adding articles and other software development material to the Koda web site.

Creating Animated GIF files in WPF

I would like to present some of the functionality that Windows Presentation Foundation (WPF) provides to viewers of my website, and I don’t want to require them to have the .NET 3.0 Framework installed. In particular I want to capture animations, both in 2D and 3D, and play them back as little filmstrips.

I’m not an expert in the field of animation and video, so my tool needs to be fairly easy to use.

With that in mind I did some looking around (the web) for appropriate tools. Unfortunately, I didn’t find anything that seemed simple enough to use. If anyone knows of a good tool please let me know.

Now, as a stubborn, old fashioned programmer, I couldn’t give up yet. I know that WPF has great imaging support, and sure enough, it also supports creating animated GIFs. After studying the MSDN documentation (I couldn’t find any external articles on the subject), I had a functional "FilmStrip" prototype.

Here’s a quick example of how it can be used. Assume that you have a window with a Viewport3D that you somehow can perform transformations/animations on. In addition you have three buttons named "Start Film Strip", "Add Frame", and "Save Film Strip".

First you declare your FilmStrip object:

private FilmStrip Film = new FilmStrip();

In the code behind you have the following click event handlers:

void StartFilmButton_Click(object sender, RoutedEventArgs e)
{
  Film.Start();
}
 
void AddFrameToFilmStripButton_Click(object sender, RoutedEventArgs e)
{
  Film.AddFrame(fViewport);
}
 
void SaveFilmStripButton_Click(object sender, RoutedEventArgs e)
{
  Film.SaveToFile(@"C:\Temp\FilmStrip.gif");
}

What you can do with this in place, is to click the Start button, followed by multiple clicks on the Add Frame button at appropriate times, finalized by a click on the save button.

That seems to be fairly straight forward. With this basic functionality operational, the next logical step would be to tie into the WPF animation framework to automate adding frames to the filmstrip. Unfortunately, the GIF file that this code creates doesn’t seem to behave quite right, at least not when I display it in IE7. What happens is that the prior frame is not cleared before the next frame is displayed. I will have to look into that at some other time. Maybe somebody already knows how to do this?

Here’s the source for the FilmStrip class:

namespace Koda.WPF
{
using System;
using System.Windows.Media.Imaging;
using System.Windows;
using System.Windows.Media;
using System.IO;
 
public class FilmStrip
{
private BitmapEncoder fEncoder;
 
protected BitmapEncoder Encoder
{
  get { return fEncoder; }
}
 
public void AddFrame(BitmapFrame frame)
{
  Encoder.Frames.Add(frame);
}
 
public void AddFrame(BitmapSource source)
{
  AddFrame(BitmapFrame.Create(source));
}
 
public void AddFrame(FrameworkElement element)
{
  RenderTargetBitmap bmp = new RenderTargetBitmap((int)element.ActualWidth,
    (int)element.ActualHeight, 1 / 96, 1 / 96, PixelFormats.Pbgra32);
  bmp.Render(element);
  AddFrame(bmp);
}
 
protected virtual BitmapEncoder CreateEncoder()
{
  return new GifBitmapEncoder();
}
 
public void SaveToFile(String fileName)
{
  using (FileStream fs = new FileStream(fileName, FileMode.Create))
  {
    Encoder.Save(fs);
  }
}
 
public void Start()
{
  fEncoder = CreateEncoder();
}
}
}