como saber quien llama a un metodo con c#

Actualmente tengo un problema en testeo que no tengo en produccion y me vi en la necesidad de hacer una traza de quien llama al metodo, asi que aproveche el impulso e hice un metodo que me muestre todos los metodos que se llamaron.

Aqui esta el metodo:


using System;
using System.Diagnostics;
private static string GetCallerName() {
var trace = new StackTrace();
var texto = Environment.NewLine;
var i = 1;
foreach (var stackFrame in trace.GetFrames()){
texto += string.Format("{0}) {1} Of {2} {3}", i, stackFrame.GetMethod().Name, stackFrame.GetMethod().ReflectedType.FullName, Environment.NewLine);
i++;
}
return texto;
}


y nos retorna algo de de este estilo:

1) GetCallerName Of ZeusNet.Core.Model.Domain.Ops.Laytimes.LaytimeCalculationPortItem
2) set_DemurrageRate Of ZeusNet.Core.Model.Domain.Ops.Laytimes.LaytimeCalculationPortItem
3) _InvokeMethodFast Of System.RuntimeMethodHandle
4) InvokeMethodFast Of System.RuntimeMethodHandle
5) Invoke Of System.Reflection.RuntimeMethodInfo
6) Invoke Of System.Reflection.RuntimeMethodInfo
7) SetValue Of System.Reflection.RuntimePropertyInfo
8) SetValue Of System.Reflection.RuntimePropertyInfo
9) Set Of NHibernate.Property.BasicSetter
10) SetPropertyValues Of NHibernate.Persister.AbstractEntityPersister
11) InitializeEntity Of NHibernate.Impl.SessionImpl
12) InitializeEntitiesAndCollections Of NHibernate.Loader.Loader
13) DoQuery Of NHibernate.Loader.Loader
14) DoQueryAndInitializeNonLazyCollections Of NHibernate.Loader.Loader
15) LoadCollection Of NHibernate.Loader.Loader
16) LoadCollection Of NHibernate.Loader.Loader
17) Initialize Of NHibernate.Loader.OneToManyLoader
18) Initialize Of NHibernate.Collection.AbstractCollectionPersister
19) InitializeCollection Of NHibernate.Impl.SessionImpl
20) Initialize Of NHibernate.Collection.PersistentCollection
21) GetEnumerator Of NHibernate.Collection.Bag
22) GetEnumerator Of NHibernate.Collection.Generic.GenericBag`1
23) ExistVoyageItineraryPort Of ZeusNet.Core.Model.Domain.Ops.Laytimes.LaytimeCalculation
24) Update Of ZeusNet.Core.Model.Domain.Ops.Laytimes.LaytimeCalculation
25) CurrentLaytimeCalculation Of ZeusNet.Core.Presentation.Operations.Laytime.LayTimeCalculators.LaytimeCalculatorPresenter
26) LoadData Of ZeusNet.Core.Presentation.Operations.Laytime.LayTimeCalculators.LaytimeCalculatorPresenter
27) LoadFixtures Of ZeusNet.Core.Presentation.Operations.Laytime.LayTimeCalculators.LaytimeCalculatorPresenter
28) LoadCharterers Of ZeusNet.Core.Presentation.Operations.Laytime.LayTimeCalculators.LaytimeCalculatorPresenter
29) _InvokeMethodFast Of System.RuntimeMethodHandle
30) InvokeMethodFast Of System.RuntimeMethodHandle
31) Invoke Of System.Reflection.RuntimeMethodInfo
32) Invoke Of System.Reflection.RuntimeMethodInfo
33) InvokeJoinpoint Of Spring.Aop.Framework.AbstractMethodInvocation
34) Proceed Of Spring.Aop.Framework.AbstractMethodInvocation
35) Execute Of Accendra.AFC.Platform.Aop.UnitOfWorkInterceptorCommand
36) ExecuteCommand Of Accendra.AFC.Platform.Context.WorkContext
37) RunUnitOfWork Of Accendra.AFC.Platform.Context.WorkContext
38) Invoke Of Accendra.AFC.Platform.Aop.UnitOfWorkInterceptor
39) Proceed Of Spring.Aop.Framework.AbstractMethodInvocation
40) Invoke Of Accendra.AFC.Platform.Aop.LogInterceptor
41) Proceed Of Spring.Aop.Framework.AbstractMethodInvocation
42) Invoke Of Spring.Aop.Framework.DynamicProxy.BaseCompositionProxy
43) LoadCharterers Of Spring.Aop.DynamicProxy.Proxy_cc2f84dc90a44991a4513fe3d0405c0d
44) VoyageChanged Of Operations_Laytime_LaytimeCalculator
45) OnSelectedIndexChanged Of System.Web.UI.WebControls.ListControl
46) RaisePostDataChangedEvent Of System.Web.UI.WebControls.DropDownList
47) System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent Of System.Web.UI.WebControls.DropDownList
48) RaiseChangedEvents Of System.Web.UI.Page
49) ProcessRequestMain Of System.Web.UI.Page
50) ProcessRequest Of System.Web.UI.Page
51) ProcessRequest Of System.Web.UI.Page
52) ProcessRequestWithNoAssert Of System.Web.UI.Page
53) ProcessRequest Of System.Web.UI.Page
54) ProcessRequest Of ASP.operations_laytime_laytimecalculator_aspx
55) System.Web.HttpApplication.IExecutionStep.Execute Of System.Web.HttpApplication+CallHandlerExecutionStep
56) ExecuteStep Of System.Web.HttpApplication
57) ResumeSteps Of System.Web.HttpApplication+ApplicationStepManager
58) ResumeStepsFromThreadPoolThread Of System.Web.HttpApplication
59) ResumeStepsWithAssert Of System.Web.HttpApplication+AsyncEventExecutionStep
60) OnAsyncEventCompletion Of System.Web.HttpApplication+AsyncEventExecutionStep
61) Complete Of System.Web.HttpAsyncResult
62) PollLockedSessionCallback Of System.Web.SessionState.SessionStateModule
63) TimerCallback_Context Of System.Threading._TimerCallback
64) runTryCode Of System.Threading.ExecutionContext
65) ExecuteCodeWithGuaranteedCleanup Of System.Runtime.CompilerServices.RuntimeHelpers
66) RunInternal Of System.Threading.ExecutionContext
67) Run Of System.Threading.ExecutionContext
68) PerformTimerCallback Of System.Threading._TimerCallback


Claro la mayoria de los metodos no tengo idea para que son, pero solo sabiendo algunos y ahora se el orden en que se ejecutaron :D
--
Atte.
Victor Hugo Saavedra
http://vhspiceros.blogspot.com

Comentarios

  1. Capri trousers are an abomination invented by gay
    men to produce women's legs look like they're cut off at
    the knee. Yuck.

    Visit my blog; 2 girls teach sex online

    ResponderEliminar

Publicar un comentario

Entradas populares de este blog

Buscar columnas en todas las tablas SQL SERVER

"is not null" o "<> Null" en Sql Server

Aplicación y Aplicativo