Unrecognized element 'providerOption' - asp.net

I am deploying an ASP.NET MVC 4 application on IIS 7.5 on a Windows 2008 R2 machine.
The app works alright locally in the Visual Studio Web development server.
But when deployed, I get a 504 http status code.
The app runs in a custom application pool under the ApplicationPoolIdentity identity and in Integrated mode. The app pool is enabled to run both 32-bit and 64-bit applications and targets v4 of the .NET framework.
The app assemblies were build targeting "Any CPU".
When I deploy the application and attempt to access it, in addition to receiving the 504 Http status code, I also see this in the event viewer.
Event Data
HRESULT 0x8007000d
PhysicalPath \\?\C:\Windows\Microsoft.NET\Framework\v4.0.30319\CONFIG\web.config
Type 3
Message Unrecognized element 'providerOption'
LineNumber 53
PreviousLine <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
ErrorLine <providerOption name="CompilerVersion" value="v4.0"/>
NextLine <providerOption name="WarnAsError" value="false"/>

The above configuration pertains to CodeDOM, a set of classes in the System.CodeDom namespace in the System.dll assembly that ASP.NET uses to generate our "code behind" classes.
The CodeDOM configuration has changed from v2 of the .NET framework to v3.5.
I missed the part where the above error gives me the path of the web.config it is complaining about. The path is C:\Windows\Microsoft.NET\Framework\v4.0.30319\CONFIG\web.config and that file did have this <providerOption> element.
I commented that out. This error is now gone.
However, I still have other issues to deal with but this one goes away. So, anyone else in the future who faces this error might use this answer as help.

Related

What would cause a VB.NET DLL to fail in IIS when it works well when called by executable code?

For the last 5-6 months I have been fighting a battle with VB code calling a c++ DLL. I have asked numerous questions on StackOverflow only to have all of them voted out of existence.
I have finally found a way of compiling my code (no help from Stackoverflow) that will work well with the C++ DLL. It appears that when I compile my VB.NET module and I use a 4.0 framework it works perfectly, no more memory issues with calling c++. Frameworks > 4.0 cause the protected memory errors.
My VB.NET code is itself a DLL and I call it from both compiled .EXE programs as well as uncompiled vb.net code from ASP.NET. When I compile it into other VB.NET programs everything works well. When I run it from ASP.NET I get;
Attempted to read or write protected memory.
This is the same error I would get when I previously compiled with a Framework > v4.0. I have modified my web.config file adding;
<compilation debug="false" targetFramework="4.0"/>
and
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<providerOption name="CompilerVersion" value="v4.0" />
<providerOption name="OptionInfer" value="true" />
<providerOption name="WarnAsError" value="false" />
</compiler>
With no change in behavior. Since the memory error is similar to what I get when I execute this same code compiled with a framework > 4.0 my assumption is IIS is executing the code with a framework > 4.0.
The questions as best I can formulate them are;
How can I verify what framework the DLL is executing in?
How can I control that framework?
Hopefully this question lasts long enough to get an answer, rather than voted down the tubes.

Azure site : Compiler Error Message: CS1056: Unexpected character '$'

I am trying to host my application in Azure but getting below error:
Compiler Error Message: CS1056: Unexpected character '$'
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.2623.0
I have used string concatenation using '$' sign.
This works fine in my local machine, but throws the compilation error.
How to set the right framework version in Azure and avoid the above exception.
Thanks,
Sharath
Lex should get credit for sending this in the correct direction. I want to confirm that this is the correct path and fixes the issue and give a little more detail. I was having the same issue and error message "Compiler Error Message: CS1056: Unexpected character '$'" when trying to deploy a ASP.NET app to Microsoft Azure App Service and indeed the solution was to add the Roslyn compiler to the project. It appears by default the built in compiler used on Microsoft Azure App Service only supports up to C# 5 language features and Roslyn is needed to compile and use the C# 6 features. Note I am deploying CS files for my project and not compiled DLL files.
Install Roslyn In Project
In Visual Studio 2017 Select "Tools" -> "NuGet Package Manager" -> "Manage NuGet Packages for Solution..."
From the tabs select "Browse" and then search for "Microsoft.CodeDom.Providers.DotNetCompilerPlatform"
Select "Microsoft.CodeDom.Providers.DotNetCompilerPlatform" from the search results then over on the right check the project name you want to add it to and then click the "Install" button.
Rebuild your Solution and make sure it still builds.
Deploy with Roslyn
You will notice installing the DotNetCompilerPlatform package added a section to your Web.config file that looks something like this, make sure this section gets added to your deployed Web.config:
<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"/>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+"/>
</compilers></system.codedom>
You will also notice installing the DotNetCompilerPlatform package and building your solution added some files to your Bin folder, make sure these files (including the whole "roslyn" folder and all the files in it) get put in the Bin folder of your deploy: Bin folder files to deploy
That was all it took to get my website back up and running with C# 6 language features, hope it helps.
You can install Microsoft.Dotnet.Compilers package and then compile your site again.
Refer this page - Project builds fine with Visual Studio but fails from the command line

ASP 5 MVC 6 (RC1) - Web API with EF 6 works locally but not deployed

I have a Web API I created in ASP 5 MVC 6 (FULL CLR). The web API references a standard .net class library, which has the entity framework 6 NUGET package installed. If I launch the web api locally (IIS express) and then try to run a method which contacts the database, everything works fine.
When I deploy the web API (I set it up in IIS), using the "Publish" command, to my DEV server (Windows Server 2012) and try to contact the same method, but on the server, I get the following exception (any other method that doesn't touch the database works):
{
"$id":"1",
"ClassName":"System.IO.FileNotFoundException",
"Message":"Could not load file or assembly 'EntityFramework,
Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
or one of its dependencies. The system cannot find the file specified.",
"Data":null,
"InnerException":null,
"HelpURL":null,
"StackTraceString":"
at CMAllocation.Web.Data.InvestorRulesRepository..ctor()\r\n
at CMAllocation.Web.CMAllocationWebApi.Controllers
.InvestorRulesController.GetInvestors()
in E:\\CMAllocation\\WebServices\\CMAllocationWebApi
\\Debug\\approot\\src\\CMAllocation.Web.CMAllocationWebApi
\\Controllers\\InvestorRulesController.cs:line 45",
"RemoteStackTraceString":null,
"RemoteStackIndex":0,
"ExceptionMethod":
"1\n.ctor\nCMAllocation.Web.Data, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null\nCMAllocation.Web.Data.InvestorRulesRepository\nVoid .ctor()",
"HResult":-2147024894,
"Source":"CMAllocation.Web.Data",
"WatsonBuckets":null,
"FileNotFound_FileName": "EntityFramework, Version=6.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089",
"FileNotFound_FusionLog":
"WRN: Assembly binding logging is turned OFF.\r\n
To enable assembly bind failure logging, set the registry value
[HKLM\\Software\\Microsoft\\Fusion!EnableLog] (DWORD) to 1.\r\n
Note: There is some performance penalty associated with
assembly bind failure logging.\r\n
To turn this feature off, remove the registry value
[HKLM\\Software\\Microsoft\\Fusion!EnableLog].\r\n"
}
Any help would be appreciated.
UPDATE I can clearly see the EF 6 dll's in the approot/packages folder:
Your server is missing 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies.
Build on the server with msbuild.
Run NuGet restore. Dave Ebbo has a good article. It is nuget restore from the cmd line.
If that doesn't work, install the EntityFramework package into the GAC on your server.

IIS 7.5 'protocolMapping' cannot be read error in web.config

When I want to just simply open an application's web.config file (IIS 7.5, Windows 7 x64) or make some changes to it using PowerShell commands, which not necessary has to do anything with the 'protocolMapping' section, the following error is thrown: "Error: The configuration section 'protocolMapping' cannot be read because it is missing a section declaration".
The exact same commands are working perfectly on IIS 8, but I need this to work in IIS 7.5 too. What can be the problem?
Things I've already tried, and do NOT solves the problem:
the applicationPool's framework, under the application is running, is set to v4.0
also the DefaultAppPool is set to v4.0 framework (however the application has a separate applicationPool)
[UPDATE]
This error comes up on multiple machines, running Windows 7 (32 and 64 bit too), even on a fresh install of Windows 7.
Try to put on web.config section this:
<configSections>
<sectionGroup name="system.serviceModel" type="System.ServiceModel.Configuration.ServiceModelSectionGroup, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="protocolMapping" type="System.ServiceModel.Configuration.ProtocolMappingSection, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</sectionGroup>
</configSections>
This solved for me
The error is generating from a misconfiguration in either web.config or applicationhost.config. It's mentioning protocol bindings so you're going to have to start trouble shooting the site bindings either through the gui or (more likely) manually editing the files. I'd start by comparing that section from a working site.

Asp.net v2.0 vs asp.net v3.5

I have my gui which has this in its webconfig:
<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>
Now when i go in the IIS and within the website properties select the asp.net version of v2.0.50727 (as i can see no higher version).. everything works fine
but now when i use another server of win 2003 i get an error
Configuration Error
Description: An error occurred during the processing of a
configuration file required to service this request. Please review the
specific error details below and modify your configuration file
appropriately.
Parser Error Message: Child nodes not allowed.
at this line:
i saw some answers which said that the server must not have v3.5... but i have selected v2.0.50727 so why do i need v3.5, also then how did it work in the previous server..
Please help..
thanks
As far as ASP.Net is concerned, 3.5 is mostly just a set of extensions for the 2.0 runtime. You still use a .Net 2.0 App Pool to run web apps built with .Net 3.5. However, you do need to make sure that .Net 3.5 is installed on the server, or the extensions won't be available.

Resources