Is there a way to still make use of the asp.net trace.axd page when switching over from the Microsoft.CSharp.CSharpCodeProvider compiler to the Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider compiler? I haven't found any web.config
compilerOptions setting that will get it to output there. My framework 4.7 compiled business classes output there fine - just not the .aspx.cs pages. Thank you.
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Our code matches in the web.config and on the page, but for some reason if we use the switch it does not output to the trace. Just to confirm in your web.config your compiler is:
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
None
0 Points
3 Posts
Trace.axd use with Rosyln Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider c...
Nov 20, 2018 01:17 PM|CrashKGM|LINK
Is there a way to still make use of the asp.net trace.axd page when switching over from the Microsoft.CSharp.CSharpCodeProvider compiler to the Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider compiler? I haven't found any web.config compilerOptions setting that will get it to output there. My framework 4.7 compiled business classes output there fine - just not the .aspx.cs pages. Thank you.
Contributor
3500 Points
1300 Posts
Re: Trace.axd use with Rosyln Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvid...
Nov 21, 2018 03:03 AM|Ackerly Xu|LINK
Hi CrashKGM,
I have had a test , trace.axd work well using the compiler.
Below is my web.config.
The compiler setting.
The result.
Best regards,
Ackerly Xu
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
None
0 Points
3 Posts
Re: Trace.axd use with Rosyln Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvid...
Nov 25, 2018 04:07 AM|CrashKGM|LINK
Thank you. I now realize if I do Trace.Write("category", "message"); it works fine. However in my web.config I had:
<system.diagnostics>
<switches>
<add name="appTraceSwitch" value="4" />
</switches>
<trace autoflush="true" indentsize="3">
<listeners>
<add name="WebPageTraceListener" type="System.Web.WebPageTraceListener, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</listeners>
</trace>
</system.diagnostics>
and then was trying to do something like:
TraceSwitch ts = (TraceSwitch)Application["appTraceSwitch"];
System.Diagnostics.Trace.WriteLineIf(ts.Level >= traceLevel, "message", "category");
that's what I can no longer get to work with Roslyn, but for now I just took that out and doing basic Trace.Write calls again - thanks again.
Contributor
3500 Points
1300 Posts
Re: Trace.axd use with Rosyln Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvid...
Nov 26, 2018 07:01 AM|Ackerly Xu|LINK
Hi CrashKGM,
If you want to use you switch in you web.config, you only need to create a new switch with the same name in your web.confg.
Below is my code.
private static TraceSwitch logSwitch = new TraceSwitch("appTraceSwitch", "This is your logLevelSwitch in the config file"); protected void Page_Load(object sender, EventArgs e) { System.Diagnostics.Trace.WriteLineIf(logSwitch.Level>=TraceLevel.Off,"messagemessagemessagemessagemessagemessagevmessagemessagemessagemessagemessagev", "category"); System.Diagnostics.Trace.WriteLine("categorycategorycategorycategorycat", "name"); Response.Write(logSwitch.DisplayName + logSwitch.Level.ToString()); }
And my web.config.
<trace enabled="true" localOnly="true" pageOutput="true" writeToDiagnosticsTrace="true"/> <system.diagnostics> <trace autoflush="true" indentsize="4"> <listeners> <add name="WebPageTraceListener" type="System.Web.WebPageTraceListener, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </listeners> </trace> <switches> <add name="appTraceSwitch" value ="4"/> </switches> </system.diagnostics>
The result.
Best regards,
Ackerly Xu
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
None
0 Points
3 Posts
Re: Trace.axd use with Rosyln Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvid...
Nov 26, 2018 01:37 PM|CrashKGM|LINK
Our code matches in the web.config and on the page, but for some reason if we use the switch it does not output to the trace. Just to confirm in your web.config your compiler is:
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
</compilers>
</system.codedom>
Thank you.
Contributor
3500 Points
1300 Posts
Re: Trace.axd use with Rosyln Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvid...
Nov 27, 2018 07:05 AM|Ackerly Xu|LINK
Hi CrashKGM,
Do you mean I need to change my compiler to have a test ?
Could you show you compiler?
What effect do you want to have?
As you could see in my image , I write
And the image shows this message in Trace Information.
If you want to know how to use switch , you could refer to the line below https://stackoverflow.com/questions/13108577/how-can-i-get-the-current-trace-switch-programatically
Best regards,
Ackerly Xu
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.