private static TraceSource CreateTraceSource(string sourceName)
        {
            // Create the trace source.  Whether or not it will actually
            // trace anything is a decision of the trace source, e.g. it
            // depends on the app.config file settings.

            TraceSource source = new TraceSource(sourceName);

            // If we're attached to the debugger, ensure that at least
            // warnings/errors are getting traced.

            if (source.Switch.Level == SourceLevels.Off
                &&
                AvTrace.IsDebuggerAttached())
            {
                // we need to assert as PT callers under a debugger can invoke this code path
                // with out having the needed permission to peform this action
                new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Assert(); // BlessedAssert
                try
                {
                    source.Switch.Level = SourceLevels.Warning;
                }
                finally
                {
                    SecurityPermission.RevertAssert();
                }
            }

            // returning source after reverting the assert to avoid
            // using exposed elements under the assert
            return(source);
        }
        private static TraceSource CreateTraceSource(string sourceName)
        {
            // Create the trace source.  Whether or not it will actually
            // trace anything is a decision of the trace source, e.g. it
            // depends on the app.config file settings.

            TraceSource source = new TraceSource(sourceName);

            // If we're attached to the debugger, ensure that at least
            // warnings/errors are getting traced.

            if (source.Switch.Level == SourceLevels.Off
                &&
                AvTrace.IsDebuggerAttached())
            {
                source.Switch.Level = SourceLevels.Warning;
            }

            // returning source after reverting the assert to avoid
            // using exposed elements under the assert
            return(source);
        }