You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PostSharp crashes with TypeInitializationException when PostSharpTrace="*" is used with PostSharpUsePipeServer=False #18
When using PostSharpTrace="*" (wildcard) together with PostSharpUsePipeServer=False, PostSharp crashes with a TypeInitializationException in CommonTrace..cctor().
The crash has two contributing factors:
The * wildcard is not recognized as a valid trace category by the PostSharp command-line parser. When PostSharpUsePipeServer=False, the MSBuild task passes /T:* on the command line, which the standalone postsharp-x64.exe rejects: POSTSHARP : error : Cannot parse the argument {/T:*} at position {20} from command line.
The error-handling code path triggers a static constructor (CommonTrace..cctor()) that calls BuildTimeLogger.GetInstance() before BuildTimeLogger.Initialize() has been called, causing a cascading TypeInitializationException: System.TypeInitializationException: The type initializer for "PostSharp.CommonTrace" threw an exception. ---> System.InvalidOperationException: Cannot call IsEnabled because Initialize has not been called. at PostSharp.Extensibility.BuildTimeLogging.BuildTimeLoggingConfiguration.IsEnabled(String category) at PostSharp.Extensibility.BuildTimeLogging.BuildTimeLogger.GetInstance(String category) at PostSharp.CommonTrace..cctor()
The process exits with code 12.
Expected Behavior
Either:
PostSharpTrace="*" should be supported as a wildcard to enable all trace categories, OR
An invalid trace category should produce a clear error message without crashing
In both cases, the error-handling code path should not access BuildTimeLogger before it has been initialized.
Workaround
Use a specific trace category name instead of the wildcard: msbuild -p:PostSharpTrace="Licensing" -p:PostSharpUsePipeServer=False ...
Activity
gfraiteur commentedon Sep 23, 2026
Fixed on
develop/2024.0by postsharp/PostSharp@4222b37f29 (PR postsharp/PostSharp#129). Ships in 2024.0.26.-- Claude for Gael Fraiteur
gfraiteur commentedon Sep 23, 2026
Released in PostSharp 2024.0.26.
-- Claude for Gael Fraiteur