Get Correlation ID

SP2013

 

Hello everyone,

Today I will talk about a piece of interesting code to retrieve the current correlation id. It’s not that I find the SharePoint error screen ugly (umm .. in fact yes), but from an aesthetic point of view, it may be interesting to present the error in a more “corporate” way.

public static class Helper{

       [DllImport(“advapi32.dll”)]

       public static extern uint EventActivityIdControl(uint controlCode, ref Guid activityId);

       public const uint EVENT_ACTIVITY_CTRL_GET_ID = 1;

       public static Guid GetCurrentProcessGuid()

       {

           var g = new Guid();

           EventActivityIdControl(EVENT_ACTIVITY_CTRL_GET_ID, ref g);

           return g;

       }

   }

 

PS: I am not the original author of the code, if he sees this post, thank you!

Hope this helps.

Christopher.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s