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.
Related
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.
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
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.
I have an extension method on HttpRequest that I'm trying to use inline on different aspx pages.
Despite I've added the correct import to the aspx I get an error saying that the method doesn't exist. The extension method works perfect on code behind.
Compiler Error Message: CS0117: 'System.Web.HttpRequest' does not contain a definition for...
In order to fix this, I had to add this web.config declaration
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" 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>
</compilers>
</system.codedom>
I found that here but I have no idea why I need this declaration.
I'm not sure what's for and I'm concerned that it might have some side effect.
Do you know why I need this declaration and how I could avoid it?
Extension methods were introduced in .NET 3.5. By default, inline code is compiled with CompilerVersion v2.0. You need to add the block you specified to instruct the runtime to compile language features introduced in .NET 3.5, hence the CompilerVersion value of "v3.5".
The problem is specific to ASP.NET, as extension methods compile in normal applications under the CLR 2.0 compiler.
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.