Monthly Archives: May 2006

Outlook 2007 Beta 2 RSS Feeds

I’ve been playing with Office 2007 Beta 2, as have many other people, and I like it. In fact, this post was composed in Word, and published straight here.

One thing I don’t seem to be able to get to the bottom of, though, is the RSS reader built into Outlook. I can set up all my feeds and get the headers at least once. The problem is that it will often just bug out on a certain feed, and no amount of fiddling will bring it back. It fires back into life if I delete the feed and recreate it, but what’s the point in that? I’ll be Googling like crazy today trying to find the problem.

I’ll get back to you later.

Backup an assembly from the GAC

Scenario : You build a new version of an assembly that needs to be deployed to GAC. You need to make sure you have a roll-back plan, but the original file that you added to the GAC (the previous version) is no longer available. It *is*, however, still in the GAC.

Problem : Windows Explorer won’t let you copy an assembly from the “C:\windows\assembly” folder.

Solution : The Command Prompt. Too many peaople, in my opinion, are way too fond of using the GUI for everything under the sun. I grew up with DOS, and was lucky enough to have been able to get comfortable with doing a lot at the command line (the same with my Linux boxes, btw).

To copy the file you want out of the gac, start a command prompt and type the following :

c:
cd\\
cd windows\\assembly\\GAC
cd
cd
copy .dll c:\\

On lines 4 and 5 above, tab completion (on later versions of windows, this is enabled by default) will help you enormously. Otherwise, you’ll need to list the directory contents a couple of times to figure out the version and assembly names.

Determine if an assembly is a debug or release build

*This code originally came from another blog, although it was written in VB over there. It has lost some elegance in the translation, but I needed a very quick solution this afternoon, and I needed it in C#, so here you go. *

I needed to determine whether several assemblies were built as “Debug” or “Release” code this afternoon. They didn’t have any debug symbols with them, so that was no help. A bit of searching led me to the code below.

private void testfile(string file)
{
	if(isAssemblyDebugBuild(file))
	{
		MessageBox.Show(String.Format("{0} seems to be a debug build",file));
	}
	else
	{
		MessageBox.Show(String.Format("{0} seems to be a release build",file));
	}
}

private bool isAssemblyDebugBuild(string filename)
{
	return isAssemblyDebugBuild(System.Reflection.Assembly.LoadFile(filename));
}

private bool isAssemblyDebugBuild(System.Reflection.Assembly assemb)
{
	bool retVal = false;
	foreach(object att in assemb.GetCustomAttributes(false))
	{
		if(att.GetType() == System.Type.GetType("System.Diagnostics.DebuggableAttribute"))
		{
			retVal = ((System.Diagnostics.DebuggableAttribute)att).IsJITTrackingEnabled;
		}
	}
	return retVal;
}

The overloaded “isAssemblyDebugBuild” method will accept either a string containing the fiull filename, or a System.Reflection.Assembly object. It will return its best guess as to whether the the assembly is a debug build, as a boolean.

To call the methods as they are (to get a MessageBox), just use something like

testfile(@"C:\myUnknownAssembly.dll");

or access the underlying methods directly :

bool isDebug = isAssemblyDebugBuild(@"C:\myUnkownAssembly.dll");

I hope someone can use this to save themselves some time.