Category Archives: .NET

So what am I up to now?

Well, about 5 weeks ago I joined Avanade as a solution Developer, and since joining I’ve had all kinds of things going on – not least of which was a trip to Seattle for an orientation / training week. It sounds terrible, b ut is actually really good. I’ll be blogging about that later.
I start my first customer facing role on Monday. I’m not going to say anything about who it is for, or what it is doing, but it *is* going to teach me new skills, and give me the opportunity to meet some more of my colleagues “in the field”

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)
		MessageBox.Show(String.Format("{0} seems to be a debug build",file));
		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


or access the underlying methods directly :

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

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

Remote Debugging Issues

My colleague, John, was having problems connecting the remote debugger to our SharePoint stage server. When connecting he got an “Access Denied” error. After spending much of the afternoon Googling for a solution, he came up with the following fix.

  1. Open an MMC session and add the Component Services snap-in. Alternatively, run “dcomcnfg.exe”
  2. Expand “Computers”
  3. Right-click on “My Computer” and hit “Properties”
  4. In the “Access Permissions” section of the “COM Security” tab, click “Edit Limits”
  5. Make sure the entry for ANONYMOUS LOGIN is allowed access to the Local machine
  6. Hit “OK”, and you’re done

Very handy thing to know about.