Determine whether the BizTalk assembly is Debug or Release build at runtime.

Recently someone raised this question in the newsgroup, they wanted to branch inside the orchestration based on the build of the assembly itself. Whenever an assembly is build with “Debug” mode, some System.Diagnostics.DebuggableAttributes are added to the assembly. One such attribute is “IsJITTrackingEnabled”, which will track information during code generation (MSIL) for the debugger.

So, we can use the simple technique of reflection to determine whether the assembly is build against “Debug” or “Release” mode by the presence or absence of IsJITTrackingEnabled attribute. The below method does exactly the same:

public static bool IsDebugBuild(System.Reflection.Assembly assembly)
{
object[] attributes = assembly.GetCustomAttributes(typeof(DebuggableAttribute), false);

if (attributes.Length == 0)
return false;//No debug attibutes, so release build

foreach (Attribute attr in attributes)
{
if (attr is DebuggableAttribute)
{
DebuggableAttribute d = attr as DebuggableAttribute;
if (d.IsJITTrackingEnabled == true) //this flag is set only for debug builds
return true; //Debug
else
return false; //Release
}
}
throw new Exception(“Cannot determine the build type”);
}

Place the above code in an utility class (external assembly), build and GAC it. Inside your Orchestration, reference the assembly, define a variable (ex: assm) of type “System.Reflection.Assembly” and call the method IsDebugBuild as shown below inside your Expression shape

assm = System.Reflection.Assembly.GetExecutingAssembly();
System.Diagnostics.Debug.WriteLine(Utility.DetermineDebugOrRelease.IsDebugBuild(assm));

Place the above code in an utility class (external assembly), build and GAC it. Inside your Orchestration, reference the assembly, define a variable (ex: assm) of type “System.Reflection.Assembly” and call the method IsDebugBuild as shown below inside your Expression shape

assm = System.Reflection.Assembly.GetExecutingAssembly();
System.Diagnostics.Debug.WriteLine(Utility.DetermineDebugOrRelease.IsDebugBuild(assm));

NOTE: This example is just to address someone’s question. You should try NOT to use this type of code in production. Because reflection is an expensive process and it doesn’t really suits well for high throughput BizTalk applications.

Nandri!
Saravana

Unofficial TechEd Itinerary

Alright,

I’m in final preparations mode for TechEd 2007, if you’re looking to chat or

just want to tell me that I’m all wrong about something, then you should be able to

find me at one of the following locals/events:

  • Saturday

    • (tentative) INETA Leadership Summit (Only third and fourth

      sessions due to flight times)

  • Sunday

  • Monday

    • Lots of Connected Systems track classes

    • Moderating the Birds of a Feather : “BizTalk, WCF and WF” at 3pm

  • Tuesday – Friday

    • Lots of Connected Systems track classes

I may also make appearances at other less publicized events … if

you’ve got a party going on … let me know. If you’ve got a party going on

and some good vodka? Definitely let me know.

As usual, [email protected] will buzz my

blackberry throughout TechEd. Or you can send me a Direct Message via Twitter.

BizTalk RFID Training

In case you missed Jon’s announcement yesterday, we are excited to announce our new Applied BizTalk RFID training course (3 days). BizTalk RFID is a new technology offering from Microsoft that is being packaged under the “BizTalk” umbrella brand, but doesn’t actually require BizTalk Server in any way (you can use it standalone). However, when you purchase BizTalk Server 2006 R2, you’ll also get a license to BizTalk RFID.
Jon is at the helm of this one and as a result, it will be outstanding training. We’ll be scheduling some open enrollments for later this fall, but if you’re interested in an onsite, let us know.

Using Google Offline: Google Gears

I’ve been waiting for this to happen, and it’s finally here: Google Gears.
Simply install Google Gears and then you can start using Google Reader through the same Web interface but against a local relational database. Once you have Gears installed, you’ll see an “offline” button (green down arrow) in the upper-right-hand link menu. When you click the button, Gears downloads all of your feeds to the local database and while it’s doing it you’ll see something like this:
Once it’s down synchronizing, you can disconnect from the network and read your feeds on the airplane like you’ve wanted to.
Right now, Google Reader is the only app that currently supports Gears but I expect that to change soon. I hear GMail, Google Calendar, and Google Docs will all support the same offline mechanism soon.

Hello Edenbrook

I’ve decided to move back into permanent employment and I have accepted a position with a London (and Manchester) based consultancy called Edenbrook, specialising in BizTalk.
They have a number of different business practices, each one specialising in a specific area of IT; they are both Java and .Net affectionados and have held Microsoft Gold Certified […]

Our first Applied Windows Workflow Foundation training is coming to London!

OK, Reading actually, but if you are in the London area and interested in workflow, then this is your chance to get a thorough understanding of not only the how of WF, but the why. We will look deep under the covers of building WF programs, hosts and activities/components. Check out the course information for more details and to register.
July 30 – August 2
Microsoft Technology Center in Reading
Course details: http://www.pluralsight.com/courses/appliedwf.aspx