public static void Trace(TraceEventType type, int traceCode, string description, ServiceInfo info, Uri from, string action, string callerIdentity, Guid iid, int instanceID, bool traceContextTransaction) { if (DiagnosticUtility.ShouldTrace(type)) { ComPlusMethodCallSchema schema = null; Guid empty = Guid.Empty; if (traceContextTransaction) { IComThreadingInfo info2 = (IComThreadingInfo)SafeNativeMethods.CoGetObjectContext(IID_IComThreadingInfo); if (info2 != null) { IObjectContextInfo info3 = info2 as IObjectContextInfo; if ((info3 != null) && info3.IsInTransaction()) { info3.GetTransactionId(out empty); } } if (empty != Guid.Empty) { schema = new ComPlusMethodCallContextTxSchema(from, info.AppID, info.Clsid, iid, action, instanceID, Thread.CurrentThread.ManagedThreadId, SafeNativeMethods.GetCurrentThreadId(), callerIdentity, empty); } } else { schema = new ComPlusMethodCallSchema(from, info.AppID, info.Clsid, iid, action, instanceID, Thread.CurrentThread.ManagedThreadId, SafeNativeMethods.GetCurrentThreadId(), callerIdentity); } if (schema != null) { TraceUtility.TraceEvent(type, traceCode, System.ServiceModel.SR.GetString(description), (TraceRecord)schema); } } }
ComThreadingInfo() { IComThreadingInfo info = (IComThreadingInfo)CoGetObjectContext(ref IID_IUnknown); apartmentType = info.GetCurrentApartmentType(); threadType = info.GetCurrentThreadType(); logicalThreadId = info.GetCurrentLogicalThreadId(); }
public static void Trace(TraceEventType type, int traceCode, string description) { if (DiagnosticUtility.ShouldTrace(type)) { Guid empty = Guid.Empty; Guid guid = Guid.Empty; IComThreadingInfo info = (IComThreadingInfo)SafeNativeMethods.CoGetObjectContext(IID_IComThreadingInfo); if (info != null) { info.GetCurrentLogicalThreadId(out empty); IObjectContextInfo info2 = info as IObjectContextInfo; if (info2 != null) { info2.GetActivityId(out guid); } } ComPlusActivitySchema schema = new ComPlusActivitySchema(guid, empty, Thread.CurrentThread.ManagedThreadId, SafeNativeMethods.GetCurrentThreadId()); TraceUtility.TraceEvent(type, traceCode, System.ServiceModel.SR.GetString(description), (TraceRecord)schema); } }
public void OnCall() { ServiceModelActivity activity = null; try { Guid empty = Guid.Empty; if (DiagnosticUtility.ShouldUseActivity) { IComThreadingInfo info = (IComThreadingInfo)SafeNativeMethods.CoGetObjectContext(ComPlusActivityTrace.IID_IComThreadingInfo); if (info != null) { info.GetCurrentLogicalThreadId(out empty); activity = ServiceModelActivity.CreateBoundedActivity(empty); } ServiceModelActivity.Start(activity, System.ServiceModel.SR.GetString("TransferringToComplus", new object[] { empty.ToString() }), ActivityType.TransferToComPlus); } ComPlusActivityTrace.Trace(TraceEventType.Verbose, 0x50016, "TraceCodeComIntegrationExecutingCall"); this.callback(this.state); } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } DiagnosticUtility.InvokeFinalHandler(exception); } finally { if (activity != null) { activity.Dispose(); activity = null; } } }