Exemple #1
0
        private string CreateSourceName()
        {
            StackTrace st = new StackTrace(this, fNeedFileInfo: false);

            if (st.FrameCount > 0)
            {
                StackFrame sf     = st.GetFrame(0);
                MethodBase method = sf.GetMethod();

                Module module = method.Module;

                RuntimeModule rtModule = module as RuntimeModule;

                if (rtModule == null)
                {
                    System.Reflection.Emit.ModuleBuilder moduleBuilder = module as System.Reflection.Emit.ModuleBuilder;
                    if (moduleBuilder != null)
                    {
                        rtModule = moduleBuilder.InternalModule;
                    }
                    else
                    {
                        throw new ArgumentException(SR.Argument_MustBeRuntimeReflectionObject);
                    }
                }

                return(rtModule.GetRuntimeAssembly().GetSimpleName());
            }

            return(null);
        }