SharePoint 2010 Dynamic Compilation of .aspx and .ascx Files with .NET 3.5
What’s the problem?
One of our colleagues, Petri, had a problem with using extension methods in his Visual Web Parts user control (.ascx file). He had developed some extension methods and tried to use them in user control:
And all he got was this error:
'System.DateTime' does not contain a definition for 'SomeExtensionMethod'
So it seems like this was compiled with a wrong compiler, and this was further revealed by looking at detailed compiler output:
Clearly not a .NET 3.5 C# compiler. All I can say is, that SharePoint is not fully compatible with .NET Framework 3.5 out-of-the-box. You cannot use 3.5 language constructs (inline code) in dynamically compiled files by default, unless…
What’s the solution?
Christian had dealed with this same problem about a year ago, so all the respect for him in documenting the problem.
To fix this issue, you need to add the following in you web application’s web.config inside configuration-element (here is C# example):
<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>
You can also use WebConfigModification classes or server-wide web.config merging to make this change in web.config.
Here is your SharePoint 2010 web.config.net35.xml merge file:
<actions>
<add path="configuration" id="{57DFD0C8-7E2D-4815-9B36-FD165903D775}">
<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>
</add>
</actions>
Place the web.config.net35.xml in 14\CONFIG folder and run (or do your PowerShell magic):
Popularity: 6% [?]
You right!! Think exactly the same
This is a great tip partіcularly to those new to the blogosphere.
Brіef but νеry acсurаte info Thanks
fοr shaгing this one. A must read article!
If you want to get a good deal from this piece of writing then
you have to apply such methods to your won
webpage.
Nice post. I was checking constantly this blog and I am impressed!
Very useful info specifically the last part I care for such info much.
I was looking for this particular info for a very long time.
Thank you and best of luck.
Thanks for sharing such a fastidious opinion, post is fastidious, thats why i have read
it completely
If some one wishes to be updated with newest technologies therefore he must be pay a quick visit this web page and be up to date every day.
Wow, awesome weblog structure! How long have you ever
been blogging for? you made blogging look easy.
The entire look of your site is excellent, let alone the content!
Yoou can share the tunes you create with people around the globe.
One of many text-editing tools forr i – OS, Hog Bay Software’s Plain – Teext iis
my current favorite, mostly because it syncs documents directly to Dropbox (the file sync software I’ve mentioned numerous times).
Consider the all advantages and disadvantages of both of them and choose the choice that iss going
to be best for you to understand this application.
Flash live video is a format that is designed for web playback, offering
high rates off compression. Thhe augmented reality based travel app is Lonely –
Planet that serves the user the city guides and displays the user of the immediate surroundings.
i -OS is the king nnow but what if Android dominates the
market in few years time.
For newest information you have to pay a visit internet and on world-wide-web I found this web page as a finest site for latest updates.|
https://www.liveinternet.ru/users/skovbjerg_hess/post460068548
The quantity of information in here is stunning!
Pro Carpet Cleaning Waterford Lakes
about us collaboration software provides enterprise-scale capabilities to meet business-critical needs such as managing content and business processes, simplifying how people find and share information across boundaries, and enabling informed decisions
This topic explains how Microsoft SharePoint Foundation is built on a set of modifications of the Integrated Request Pipeline of Internet Information Services (IIS) and Microsoft ASP.NET. contact us
If you are alone try ouderen seks for sexy chat experience with hot ladies! Visit for pleasure!
This is great! Thank you for sharing your insight about this. We also deal with this kind of matter in https://emergencytorontolocksmith.ca/
Sexe Transexuelle Saint Etienne is web place with fine ladies ready for casual contacts with you
Find fine ladies for casual chat contacts in France only at transexuelle toulouse
Thanks for any other informative website. Where else could I am getting that kind of information written in such a perfect manner? I have a challenge that I’m simply now running on, and I have been at the look out for such info.