Error registering WCF host in Windows Vista (HTTP could not register URL http://+:80)

March 27, 2010 | In Development | No Comments

This is an error encountered by one of my team when trying to run up a WCF host on a Windows Vista machine.  The actual exception is an

AddressAccessDeniedException

with the error message

HTTP could not register URL http://+:80/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details)

The Microsoft site (http://go.microsoft.com/fwlink/?LinkId=70353) does have a solution to the problem using httpcfg and netsh. However the far simpler solution is to run Visual Studio as Administrator

You can do that by right-clicking the shortcut for Visual Studio and selecting Run as adminstrator, or to permanently run as Administrator, right-click and select Properties. Find the Compatibility tab and check the Run this program as administrator checkbo€x.

C# Image from a byte array (and back again)

March 19, 2010 | In Development | No Comments

Quick code sample for transforming a .NET System.Drawing.Image into a byte array:

public byte[] imageToByteArray(Image imageIn)
{
    MemoryStream ms = new MemoryStream();
    imageIn.Save(ms,System.Drawing.Imaging.ImageFormat.Gif);
    return ms.ToArray();
}
and conversely, turning a byte array into an image:

public Image byteArrayToImage(byte[] byteArrayIn)
{
    MemoryStream ms = new MemoryStream(byteArrayIn);
    Image returnImage = Image.FromStream(ms);
    return returnImage;
}

Class not registered error in Windows 7 for ActiveX control

January 13, 2010 | In Development | No Comments

I recently had cause to use an ActiveX control in a Windows Forms project.  I was actually building a WPF application, that required a specific control that was ActiveX based.  This is not a very pretty thing; I wrapped the control in a Windows Forms user control within a WPF User Control.

Anyhow, this worked fine on my XP machine but not on my Windows 7 machine.  The solution would compile, but when I tried to instantiate the control I received the following error in Visual Studio:

Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))

On the line:

((System.ComponentModel.ISupportInitialize)(this.myControl)).EndInit();

The reason was that the Windows 7 machine is 64-bit, while the XP one was 32-bit.  The projects in the solutions need to be built to target the x86 platform.  This is an option on the project properties, found from:

Project -> Properties -> Build -> Platform Target

« Previous PageNext Page »

Login | XFN| WP
Powered by WordPress with cmb-web Theme design by Christian Bridge-Harrington.
Blog feed. Valid XHTML and CSS. ^Top^