Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

In an OOTB SharePoint 2010 Server installation, if you use C# 3 in your code-in-front, it doesn't compile, since the C# 2 compiler is used to compile the markup. (At least for me - SharePoint 2010 Server on Windows 7).

So how do you enable the use of C# 3 and .NET 3.5 for ASCX and ASPX files in SharePoint 2010? If I use var or extension methods, my web parts and page layouts won't compile.

share|improve this question
add comment

2 Answers

Won't compile?? Are you referring to Visual Studio Error OR Runtime Error?

SharePoint 2010 is based on .net 3.5 and it will work fine.

if it's Visual Studio change the project framework to 3.5

share|improve this answer
    
Runtime error, when SharePoint is trying to load the user control. Everything looks fine in Visual Studio; the project framework version is 3.5 and everything "compiles" from a Visual Studio point of view. The error doesn't appear until the control is actually loaded by SharePoint. –  ScarePoint Feb 16 '11 at 8:28
add comment
up vote 0 down vote accepted

SharePoint 2010, despite being "built on .NET 3.5", requires modifications to the web.config of any Web Application that should compile controls and layouts using .NET 3.5.

These modifications can either be applied directly to the web.config file of the Web Application, or one of the two SharePoint methods for web.config modifications can be used:

share|improve this answer
    
Could you elaborate on what's not working and what you need to modify in the web.config?? I've not yet experienced any issues with this for any of my SP2010 projects! –  Wictor Wilen MCA MCM MVP Feb 16 '11 at 10:18
    
In an OOTB SharePoint 2010 Server installation, if you use C# 3 in your code-in-front, it doesn't compile, since the C# 2 compiler is used to compile the markup. At least for me. –  ScarePoint Feb 16 '11 at 15:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.