Problems updating an application in IIS - asp.net

I have an application written in aspx. The application, launching it from visual studio 2017 works correctly, using any browser.
But when publishing it, and running it on the server, I get the following error:
Parser error message: Could not locate provider type CodeDom "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35".
I have tried with all the versions available in the Nuget Package Manager and I always get the same error, changing the installed version.
What I do is publish the application in the directory and upload it to any directory on the server. Enter the ASPX of the project and I get that error.
Is there any way to solve this?
The project was already installed previously, and I just have to update the source.
The project settings
The two extensions that give me problems
I have read in multiple sites that changing the version of the CodeDom, and I have followed the instructions to the letter and it has not worked

Just need to comment system.codedom tag in web.config file this work for me. like this
<!--<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers>
</system.codedom>-->

Related

Razor & null propagation - not working under explicit C# 6 MVC 5 project

Current project:
ASP.NET 4.6.2
MVC 5
Visual Studio 2015 Community v14.0.25431.01 Update 3
Installed the CodeDOM Providers for .NET Compiler nuget package via Project -> Install C# 6
Confirmed that I do have the compiler element in my Web.Config and that it is referencing C# 6
My Razor code:
#if(Session["Type"]?.ToString() == "Insurance") {
<text>policy of insurance</text>
} else if(Session["Type"]?.ToString() == "Warranty") {
<text>policy of warranty</text>
} else {
<text>protection policy</text>
}
Visual Studio explicitly flags this with an error,
Feature 'null propagating operator' is not available in C# 5. Please
use language version 6 or greater.
And Visual Studio is explicitly using C# 6:
When I try to run the page itself, I get an error:
CS1525: Invalid expression term '.'
which shows that it is explicitly going after the period following the question mark.
This project was explicitly started as a C# 6 project, and I am quite confused as to why it is derping back to C#5.
Another strange issue: this is working just fine both in debug as well as on my local test setup (I publish to the filesystem, view using local IIS), but when I upload to the server (which has many, many other C#6 sites) it craps out. This is the first razor-side quirk I have ever run across that actually throws an error this badly.
I was having a similar problem and found that I was missing the following from my Web.config file:
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers>
</system.codedom>

I cant remove roslyn from published ASP .NET Website using various methods

I am attempting to publish a Webforms website and noticed that the bin folder contains the 'roslyn' subfolder.
After researching it appears that removing 2 nugget packages would resolve the issue.
The problem is that removing the packages doesn't work.
I tried the Nuget package manager console:
uninstall-package Microsoft.CodeDom.Providers.DotNetCompilerPlatform
uninstall-package Microsoft.Net.Compilers
I also tried updating the web.config (and removing the references):
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers>
</system.codedom>
I still get the 'roslyn' folder when publishing.
Is this issue possible because the Visual Studio solution was created in a earlier version of VS but the web project was created under VS2015?
I know this is old, but maybe it still helps someone.
The reason you still get the 'roslyn' folder is your .csproj project file. Open it for editing and remove the <Target ...> tag (incl. subtags) referencing the 2 NuGet packages you had to remove the references to.
In my case, there was only one (Microsoft.CodeDom.Providers.DotNetCompilerPlatform), but according to this question, there might be tags for both (see Brian's answer).

CodeDom provider can't be located after another application deployed

I had two web applications deployed in a site under IIS 7.5
site.com/myApp
site.com/anotherMyApp
Now another devs deployed their app as root application
site.com/
Now when I access site.com/myApp or /anotherMyApp it throws:
The CodeDom provider type
"Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider,
Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35" could not be
located.
Source error :
Line 54: <system.codedom>
Line 55: <compilers>
Line 56: <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
Line 57: <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
Line 58: </compilers>
Source File: C:\inetpub\wwwrootprettysite\THEIR APPLICATION\web.config
Questions
Why is this happening?
Why is the "source error" in their application's webconfig and how does it affect my application?
How do I fix my applications without breaking theirs?
To clarify :
Application hierarchy is correct, their application should be
installed in root.
.NET framework installed is 4.5.2
Their application is using Roslyn compiler which is supplied in bin/roslyn
My applications web.configs have no <system.codedom> section.
Your app inherits the config from its parent app, and your app doesn't have Microsoft.CodeDom.Providers.DotNetCompilerPlatform. That's why you see that error. There are several options.
Override system.codedom setting in your web.config
Install Microsoft.CodeDom.Providers.DotNetCompilerPlatform nupkg in your app

Stack trace in website project, when debug = false

We have a website project. We are logging unhanded exceptions via a appdomain level exception handler.
When we set debug= true in web.config, the exception log is showing the offending line numbers in the stack trace.
But when we set debug = false, in web.config, log is not displaying the line numbers.
We are not in a position to convert the website project in to webapplication project type at this time. Its legacy application and almost all the code is in aspx pages. We also need to leave the project in 'updatable' mode. i.e. We can't user pre-compile option. We are generating pdb files.
Is there anyway to tell this kind of website projects to generate the pdb files, and show the line numbers in the stack trace?
Add compilerOptions="/debug:pdbonly" as an attribute to <compiler> in your web.config file:
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" compilerOptions="/debug:pdbonly" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="WarnAsError" value="false"/>
</compiler><!-- removed vb.net stuff -->
</compilers>
</system.codedom>
Here's some more info on setting up compiler options in ASP.NET:
http://msdn.microsoft.com/en-us/library/a15ebt6c.aspx

How to specify a CompilerVersion for aspnet_compiler.exe without a web.config?

When you precompile a directory that doesn't contain a web.config, the aspnet_compiler.exe defaults to CompilerVersion 2.0 and 3.5 code fails to compile. Is the following minimal web.config the only way to specify the CompilerVersion?
<?xml version="1.0"?>
<configuration>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4"
type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
</compilers>
</system.codedom>
</configuration>
We integrated asp.net precompilation with our build and integration environments and don't use web.configs for our control library components
Here you can find its parameters. Also note that ASP.NET Compilation tool is not available with versions of ASP.NET earlier than ASP.NET version 2.0.
For .NET 2.0 these are the steps you need to do
Start > run and type cmd.
set path=%windir%\Microsoft.NET\Framework\v2.0.50727
aspnet_compiler –v / –p c:\myproject\testsite c:\testcompile
I think that for other versions of .NET you have to cd to corresponding directory.
Also read this. You might find it useful.

Resources