Yearly Archives: 2006

Migrating .net application to iis7

When you initially try to run a web application with IIS7, it’ll bitch at you and tell you to either migrate the application or run it in a classic app pool.  I decided I would migrate my application since I’m sure I’ll have little choice in the future.  The error page is fairly convenient and tells you which command to run to migrate the website:

%systemroot%system32inetsrvAPPCMD.EXE migrate config “Default Web Site/YourApp”

This is great and all, but when I tried to run the command, I received the following error:

ERROR ( message:Configuration error
Filename: \?C:Windowssystem32inetsrvconfigapplicationHost.config
Line Number: 0
Description: Cannot read configuration file
. )

Now, first let me congratulate Microsoft on their extremely informative error message.  Not to mention the creativity used for formatting the error message. Way to go!  After staring at the monitor for a while, I figured that I would try running the cmd.exe as an administrator.  This solved the issue, and everything is happy.

One way to run the cmd.exe as administrator is by going through the start menu, right click Command Prompt and select Run As Administrator.  Executing the migration command in the administrator command prompt will successfully migrate your website.
 

Run msi with elevated privileges in Vista

I installed an “older” msi (QuickCode.net for vs.net 2005) on my vista box, tonight, and it apparently runs a custom action to register an assembly that Vista doesn’t like so much.  That custom action requires elevated priviledges and the install will bomb if you try to run it under a typical user account.  So… I created a batch file that calls msiexec.  You can run the batch file as an administrator and everything installs as it should.  I copied the msi to a temp directory (C:temp) and created the batch file as follows:

msiexec /i c:tempQuickCodeSetup2005.msi

Then all you have to do is right-click the batch file and select “Run as administrator”

 

Ubuntu and Beryl

My outlook on linux is changing as time goes on.  It might be that I’m playing with Linux this time, rather than racing to get a server running.  I had a pretty pleasant experience tonight with Ubuntu.  Apparently I originally installed the Dapper release (v6.06) yesterday… A click or two with the Synaptic Package Manager and around 20 minutes later, I’m now running Ubuntu Edgy (v6.10).  That amazes me… no compiling the kernel manually, no lengthy command-line statements just to install/upgrade certain parts of the OS.  It is how it should be.  Nice and easy…

After updating the OS to the latest version, I wanted to see if Linux could actually outperform Vista.  A couple clicks later (I had to add the specific Beryl repository information to Synaptic) and after following some good instructions I’m running Beryl on top of Gnome…

Beryl is a desktop/window manager based on OpenGL.  So it provides cool window movements, transitions, themes, etc.  It puts Vista’s Aero desktop to shame

There are no hardware ratings here.  Nope… Everything just works…  Opacities, transitions, effects… and the theme choices available for Beryl are amazing.  You can modify anything and everything related to windows.  One minor thing to note is that I’m using AIGLX rather than XGL.. it seems like the KDE/Gnome war all over again to me, but whatever… I’m just using the one that worked the easiest on my laptop.

As far as performance goes, I’m not noticing any degraded performance… granted I’m not playing games on the laptop, I’m just using it for surfing and development type activities.  It’s easy enough to turn off Beryl if I do find that I need to run a graphics intensive app.

Perhaps I’ll install the Kiba dock or gnome-dock at some point in the future… I haven’t fully decided yet, though. 

My experience with Vista and Ubuntu

I got a new Dell Inspiron 1300 today… I wasn’t looking for a desktop replacement, but rather just a laptop that can run various applications and works while I’m away from my office. 

After I watched the FedEx truck drive by my house & then see the status change online to “customer not home,” I sat around for a few hours until I could pick up the boxes from the local office.  Thanks FedEx…way to go the extra mile…

Anyway… so now I have my computer and the first thing I did was throw away all the shit that Dell gives you.  5 cds of worthless crap… AOL offers, Roxio crap, and all other crapware offers they bundle… A suggestion to Dell… provide an option at checkout time to not include all of that crap.

So before I could dive into their install of XP, I threw in a Vista dvd and started installing it. 

Vista

MS finally got rid of their ancient DOS based installer and replaced it with a more modern GUI.  One extremely nice feature is that you can now provide drivers via disk drives, cd/dvds or usb drives.  They also provide a relatively simple disk utility to partition/format disks.  Overall the experience is pleasant.

The install process seemed to be quicker than installing XP.  A tip of the hat goes to MS as the install only needs to reboot 2 times.  Who knows… maybe with VistaXL Ultimate Kickass v2.1 they’ll figure out how to install it with 0 or 1 reboot.  Anyway, the install finished before the end of an hour long show about the history of ecstasy; it took about a 1/2 hour.  Apparently the PC scores a 1.0 on the Vista experience scale… This automatically disables the annoying transparent title bars, thankfully.  Apparently after talking with someone who knows more about Vista scores than I do, I have a pretty crappy box.  Basically it’s at the bottom of the scale.  sweet…

This link is useful for how to get rid of the gay “Favorites” addition to Windows Explorer

Man… talk about locking down the OS… I got 4 confirmation dialogs when I tried to create a folder.  This should be a real joy to work with daily…

Total Install Time: ~1/2 hour 

Ubuntu

Well.. Ubuntu trumps MS with it’s installer… not only is it a Gui, it goes a step further and sets up a live cd.  So basically it gives you Ubuntu loaded directly off the cd.  Very cool… it allows you to surf the internet (using Firefox) among accessing all other applications and utils that you would come to expect from a linux distro.  Note, this analysis of the live cd is coming from a relative Linux retard, so take what I just wrote with a grain of salt.

Total Install Time: ~15 Minutes

 

After a few joyous outbursts, I realized that grub (the linux boot loader) was not detecting my Vista install properly.  Thanks to this thread, adding the following to /boot/grub/menu.lst did the charm… The main point to mention is that it reads rootnoverify, rather than just root.  If you’re reading this for an answer to the same thing, make sure you have the correct disk and partition specified for where your Vista install is located. 

title                Windows Vista
rootnoverify (hd0,1)
savedefault
chainloader +1

 

A generic api modification

In an attempt to become more comfortable with generics, I’m trying to find reasonable places to use them other than just for collections, etc.  This is one example:

I had a helper method that returns an object from nHibernate based on the supplied id:

public object GetObjectById(Type type, int id)

{

    if (this._activeSession != null)

    {

        return this._activeSession.Load(type, id);

    }

    else

    {

        throw new NullReferenceException(“The repository doesn’t have an active session”);

    }

}

Which I replaced with:

public T GetObjectById<T>(int id)

{

    if (this._activeSession != null)

    {

        return (T)this._activeSession.Load(typeof(T), id);

    }

    else

    {

        throw new NullReferenceException(“The repository doesn’t have an active session”);

    }

}

While it doesn’t really change anything for how the object is retrieved, it does simplify how I call the method.  Instead of having to write something like: 

Property property = MyHelperClass.GetObjectById(typeof(Property), id) as Property;

I instead write the following:

Property property = MyHelperClass.GetObjectById<Property>(id);

So in the future when I upgrade to nHibernate 1.2+, this should make the transition smoother.  nHibernate 1.2 supports generics among other things.

[Update] – I upgraded to nHibernate 1.2.  So my helper function looks like:

public T GetObjectById<T>(int id)

{

    if (this._activeSession != null)

    {

        return this._activeSession.Load<T>(id);

    }

    else

    {

        throw new NullReferenceException(“The repository doesn’t have an active session”);

    }

}

Molly

I adopted a dog (Molly) this month.  She was born in Tennessee but has been living up at my cabin for the last 5 years.  Molly is a pure bread Britney and I think she has a nipple fetish… Not my nipples, you sick bastards, but she sucks on toys like she missed out on something as a pup.  She seems to be enjoying city life since she came here.  I’ve taken her to a park close by, where she promptly harassed the local goose population.  Other than that, she has successfully eaten the head off her gorilla toy.  All and all it’s been an exciting last couple days…  She is a bit overweight, so I’m trying to get that under control for the holiday season… Hell, maybe she’ll make a New Years resolution about it ;).  Anyway, I’ll keep posting more pictures as the days ahead become memories. 

 

Molly with a toy

 

Also, I posted some pictures from this years deer hunting expedition at my cabin. 

Text description for enum values

I wanted to add text descriptions to my enum values; similar to overriding ToString on a class.  This is what I came up with, using the beauty of generics:

A sample enum implementing my custom description attribute:

public enum MyEnum

{

    [EnumDescription(“Funky chicken walks again!”)]

    FunkyChicken = 0,

    [EnumDescription(“Doctor?”)]

    Doctor = 1

}

 

This next code block defines the custom attribute:

[AttributeUsage(AttributeTargets.Field)]

public class EnumDescriptionAttribute : Attribute

{

    private string _text = “”;

 

    /// <summary>

    /// Text describing the enum value

    /// </summary>

    public string Text

    {

        get { return this._text; }

    }

 

    /// <summary>

    /// Instantiates the EnumDescriptionAttribute object

    /// </summary>

    /// <param name=”text”>Description of the enum value</param>

    public EnumDescriptionAttribute(string text)

    {

        _text = text;

    }

}

 

Finally, a static method that prints the attribute from any enum, using generics:

static StringDictionary _enumDescriptions = new StringDictionary();

public static string GetEnumDescription<EnumType>(EnumType @enum)

{

    Type enumType = @enum.GetType();

    string key = enumType.ToString() + “___” +  @enum.ToString();

    if (_enumDescriptions[key] == null)

    {

        FieldInfo info = enumType.GetField(@enum.ToString());

        if (info != null)

        {

            EnumDescriptionAttribute[] attributes = (EnumDescriptionAttribute[])info.GetCustomAttributes(typeof(EnumDescriptionAttribute), false);

            if (attributes != null && attributes.Length > 0)

            {

                _enumDescriptions[key] = attributes[0].Text;

                return _enumDescriptions[key];

            }

        }

        _enumDescriptions[key] = @enum.ToString();

    }

    return _enumDescriptions[key];

}


For performance reasons, the StringDictionary is used to cache the values.  Reflection tends to be expensive, so why not cache things? 🙂

Ctrl-s hotkey functionality for Community Server blog editor

Because the post editor uses postbacks, this doesn't feel like a native app.. but it's the best I can do w/ the design.  This will add a key mapping for ctrl-s so that it does the same as the "Save and Continue Writing" button.

Add this to the bottom of ~/ControlPanel/Blogs/CreateEditBlogPost.aspx

 

<script language="javascript">

var isSaving = false;
function DoKeyCommand(evt)
{
var key = (evt.which || evt.charCode || evt.keyCode);
var stringKey = String.fromCharCode(key).toLowerCase();
var cmd = '';

if (!evt || !evt.ctrlKey) return true;

switch (stringKey)
{
case 's':
{
if (isSaving) return false;
isSaving = true;
if (evt.preventDefault) {
evt.preventDefault();
evt.stopPropagation();
} else {
evt.returnValue = false;
evt.cancelBubble = true;
}
WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$ctl00$TaskRegion$Editor1$SaveEditButton", "", true, "", "", false, true));

return false;
}
};
return true;
}
if (document.addEventListener)
{
document.addEventListener("keypress", DoKeyCommand, true);
}
else if (document.attachEvent)
{
document.attachEvent("onkeydown", function(evt) {DoKeyCommand(evt)});
}

</script>

 

Community Server hosted…

I have to admit that I'm somewhat surprised at the pricing for the hosted version of Community Server.  They seem to be ignoring individual users and small companies with their pricing.  In my humble opinion, if they added a starter account for $5 or $10 per month, they could cater to the masses.  That would be a small enough price jump for people to consider not going with free alternatives: WordPress, Flickr, and ProBoards.   There is an obvious benefit to having blogs, forums, galleries, etc that share a common url and theme.

I definitely see the convenience hosted software packages have to offer, but man… when you have competitors offering similar services for free, it's hard for the "little guy" to justify signing up for $50 per month.  But who knows… maybe Telligent just doesn't want to cater to that market.