I am trying to deploy two ASP.NET Application onto IIS 7. The first application I copied and pasted under wwwRooT folder and set Application Pool as Asp.NET 4.0 Integrated. For the second one, I created one virtual directory and set the Application Pool the same as the first application.
The first one works well, but the second one got exception:
The value for the 'compilerVersion' attribute in the provider options
must be 'v4.0' or later if you are compiling for version 4.0 or later of the .NET
Framework. To compile this Web application for version 3.5 or earlier of the .NET
Framework, remove the 'targetFramework' attribute from the element of
the Web.config file.
I had a similar problem and had to tell ASP.NET in configuration to use the 3.5 compiler as follows by modifying Web.config.
I've copied and pasted the following from my code. You have to change value="v3.5" to value="v4.0". The compiler type strings might also change.
<configuration>
<!-- ... other configuraiton stuff ... -->
<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>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="OptionInfer" value="true"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
</compilers>
</system.codedom>
</configuration>
In my case the 2.0 compiler was being used instead of 3.5. I was working in an IIS 7, ASP.NET Website project.
You might glean additional insight from:
http://msdn.microsoft.com/en-us/library/system.codedom.aspx
http://msdn.microsoft.com/en-us/library/a15ebt6c%28VS.80%29.aspx
Related
I got a very weird error after my computer was a little messed up with deleting various versions of VSs and SQL Servers. It seems like i fixed the project setup and had been a "good girl" following Microsoft's advices. However here is the error!when I open my project I get this window. From what I found it that VS 2012 for web by default targets 4.5 framework, so sound like my error just should not be happening.
I already tried following the second option and installing
whatever it wants,unfortunately nothing has changed error message
any suggestions that wont need me to re-install the the whole thing?
Try the web.config as this is the area where the error will most likely reside. You can 'force' the web.config to be a specific version and I would add both c# and vb/net so they are always there. I have a web.config template I start all my projects with. Below is a cut of the part I believe you need. Just change the value of the .net
<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>
<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="v3.5"/>
<providerOption name="OptionInfer" value="true"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
</compilers>
</system.codedom>
i can add a define to a WinForms project through the Project Properties:
How do i add a define to an ASP.net solution?
Update: Here's what Visual Studio 2010 looks like when working in an ASP.net solution:
Solution Explorer > WebApplicationProject (Name of your Web Application) > Properties > Build:
Have you tried using the compilerOptions attribute of the compilerv element in web.config? Like so:
<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"
compilerOptions="/define:TRACE">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
....
Should do the trick I think...
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.
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
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.