search blog
most popular
MCP MCTS MCT MVP

How to: Get up and running with .NET 3.5 in your SharePoint environment 

Since I've been a bit on the lazy side when it comes to the blog (due to multiple reasons..), I'm thinking about writing up an article-series where I'll talk about .NET 3.5 and what it has to offer when used in conjunction with SharePoint. Any input is welcome, of course :)

Introduction

In this article I will try to get you up and running with the .NET 3.5 framework in your SharePoint environment, just like I've previously described how you can get AJAX and Silverlight 2.0 up and running:

I will now let .NET 3.5 be a part of some of my upcoming SharePoint projects, and because of that I thought it could be a good thing to blog about it if there's anyone out there looking to do the same!

Prerequisites before we get started

In order to follow along, I assume the following few bulletpoints are in place:

  • Microsoft .NET 3.5 Framework is installed on the front-end server
  • You already have got a Web Application on which you want to do these changes

Add support for .NET 3.5 in SharePoint (WSS 3.0 or MOSS 2007 alike)

Here you will find a manual step by step instruction on what web.config values to set in order for .NET 3.5 to work properly with your SharePoint installation.

Note: I've added some linebreaks in order for the text to show up properly in my blog, you may remove them if you want your web.config to be pretty ;)

Note2: All additions to any elements in the web.config file should be added at the bottom/end of each element unless excplicitly stated otherwise.

1) Add the following snippet inside the <configSections> element

<sectionGroup name="system.web.extensions"
                type="System.Web.Configuration.SystemWebExtensionsSectionGroup,
                System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
                PublicKeyToken=31BF3856AD364E35">
    <sectionGroup name="scripting"
                type="System.Web.Configuration.ScriptingSectionGroup,
                System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
                PublicKeyToken=31BF3856AD364E35">
       <section name="scriptResourceHandler"
                type="System.Web.Configuration.ScriptingScriptResourceHandlerSection,
                System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
                PublicKeyToken=31BF3856AD364E35" requirePermission="false"
                allowDefinition="MachineToApplication"/>
       <sectionGroup name="webServices"
                    type="System.Web.Configuration.ScriptingWebServicesSectionGroup,
                    System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
                    PublicKeyToken=31BF3856AD364E35">
        <section name="jsonSerialization"
                type="System.Web.Configuration.ScriptingJsonSerializationSection,
                System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
                PublicKeyToken=31BF3856AD364E35" requirePermission="false"
                allowDefinition="Everywhere" />
        <section name="profileService"
                type="System.Web.Configuration.ScriptingProfileServiceSection,
                System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
                PublicKeyToken=31BF3856AD364E35" requirePermission="false"
                allowDefinition="MachineToApplication" />
        <section name="authenticationService"
                type="System.Web.Configuration.ScriptingAuthenticationServiceSection,
                System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
                PublicKeyToken=31BF3856AD364E35" requirePermission="false"
                allowDefinition="MachineToApplication" />
        <section name="roleService"   
                type="System.Web.Configuration.ScriptingRoleServiceSection,
                System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
                PublicKeyToken=31BF3856AD364E35" requirePermission="false"
                allowDefinition="MachineToApplication" />
      </sectionGroup>
    </sectionGroup>
  </sectionGroup>

2) Add the following snippet inside the <pages> element

<controls>
  <add tagPrefix="asp" namespace="System.Web.UI"
        assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
        PublicKeyToken=31BF3856AD364E35"/>
  <add tagPrefix="asp" namespace="System.Web.UI.WebControls"
        assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
        PublicKeyToken=31BF3856AD364E35"/>
</controls>

3) Add the following snippet inside the <assemblies> element

<add assembly="System.Core,
    Version=3.5.0.0, Culture=neutral,
    PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions,
    Version=3.5.0.0, Culture=neutral,
    PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.DataSetExtensions,
    Version=3.5.0.0, Culture=neutral,
    PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq,
    Version=3.5.0.0, Culture=neutral,
    PublicKeyToken=B77A5C561934E089"/>

4) Add the following snippet inside the <httpHandlers> element

<add verb="*" path="*.asmx" validate="false"
    type="System.Web.Script.Services.ScriptHandlerFactory,
    System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
    PublicKeyToken=31BF3856AD364E35"/>
<add verb="*" path="*_AppService.axd" validate="false"
    type="System.Web.Script.Services.ScriptHandlerFactory,
    System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
    PublicKeyToken=31BF3856AD364E35"/>
<add verb="GET,HEAD" path="ScriptResource.axd"
    type="System.Web.Handlers.ScriptResourceHandler,
    System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
    PublicKeyToken=31BF3856AD364E35" validate="false"/>

5) Add the following snippet inside the <httpModules> element

<add name="ScriptModule"
    type="System.Web.Handlers.ScriptModule,
    System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
    PublicKeyToken=31BF3856AD364E35"/>

6) Add the following snippet inside the <SafeControls> element

<SafeControl Assembly="System.Web.Silverlight,
            Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            Namespace="System.Web.UI.SilverlightControls" TypeName="*" Safe="True" />
<SafeControl Assembly="System.Web.Extensions,
            Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            Namespace="System.Web.UI" TypeName="*" Safe="True" />

7) Add the following snippet inside the <configuration> element

    <system.web.extensions>
      <scripting>
        <webServices>
        </webServices>
      </scripting>
    </system.web.extensions>
    <system.webServer>
      <validation validateIntegratedModeConfiguration="false"/>
      <modules>
        <add name="ScriptModule" preCondition="integratedMode"
            type="System.Web.Handlers.ScriptModule,
            System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
            PublicKeyToken=31bf3856ad364e35"/>
      </modules>
      <handlers>
        <remove name="WebServiceHandlerFactory-Integrated" />
        <add name="ScriptHandlerFactory" verb="*"
            path="*.asmx" preCondition="integratedMode"
            type="System.Web.Script.Services.ScriptHandlerFactory,
            System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
            PublicKeyToken=31bf3856ad364e35"/>
        <add name="ScriptHandlerFactoryAppServices" verb="*"
            path="*_AppService.axd" preCondition="integratedMode"
            type="System.Web.Script.Services.ScriptHandlerFactory,
            System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
            PublicKeyToken=31bf3856ad364e35"/>
        <add name="ScriptResource" preCondition="integratedMode"
            verb="GET,HEAD" path="ScriptResource.axd"
            type="System.Web.Handlers.ScriptResourceHandler,
            System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
            PublicKeyToken=31bf3856ad364e35" />
      </handlers>
    </system.webServer> 
    <system.webServer>
       <validation validateIntegratedModeConfiguration="false"/>
       <modules>
         <remove name="ScriptModule" />
         <add name="ScriptModule" preCondition="managedHandler"
            type="System.Web.Handlers.ScriptModule,
            System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
            PublicKeyToken=31BF3856AD364E35"/>
       </modules>
       <handlers>
         <remove name="WebServiceHandlerFactory-Integrated"/>
         <remove name="ScriptHandlerFactory" />
         <remove name="ScriptHandlerFactoryAppServices" />
         <remove name="ScriptResource" />
         <add name="ScriptHandlerFactory" verb="*" path="*.asmx"
            preCondition="integratedMode"
            type="System.Web.Script.Services.ScriptHandlerFactory,
            System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
            PublicKeyToken=31BF3856AD364E35"/>
         <add name="ScriptHandlerFactoryAppServices" verb="*"
            path="*_AppService.axd"
            preCondition="integratedMode"
            type="System.Web.Script.Services.ScriptHandlerFactory,
            System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
            PublicKeyToken=31BF3856AD364E35"/>
         <add name="ScriptResource" preCondition="integratedMode"
            verb="GET,HEAD" path="ScriptResource.axd"
            type="System.Web.Handlers.ScriptResourceHandler,
            System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
            PublicKeyToken=31BF3856AD364E35" />
       </handlers>
    </system.webServer>

8) You're done

When you've added the needed tags, you're all set - you can now run your .NET 3.5 applications inside SharePoint (of course, this applies to the web application where you just added these settings.

To see that your site still works, do the following:

  • IISRESET
  • Launch your site where you've made the changes!
  • Cross your fingers

Cool, what's next?

Well, if you've managed to get your site up and running - you can now create webparts, features, controls or whatever you'd like to create and have them published to your site.

This article describes how you do these things manually, but what if you want to do these things automatically somehow? Is that possible?
- Yes, but that's going to be covered in an upcoming blogpost

Please leave some comments

As you might know, I like to get feedback and usually answers all mails/comments when I've got the time. Please leave any feedback, suggestions or opinions in the comments below or mail me/use the MSN gadget.

Thanks for tuning in, now I'm feeling the blog-flow again - cheers

 
Posted on 22-Sep-08 by Tobias Zimmergren
34 Comments  |  Trackback Url  |  Link to this post | Bookmark this post with:        
Tags: .NET 3.5, AJAX, SharePoint, WSS 3.0
 

Links to this post (Trackbacks/Pingbacks)

Comments

Monday, 22 Sep 2008 08:20 by Daniel Bugday
Nice post Zimmer :)

Monday, 22 Sep 2008 10:29 by TJSaynor
"....you can now run your .NET 2.5 applications inside SharePoint....." :-) I think you may have a typo, 2 = 3? Worth thinking about the bindingRedirect(s) for those of us who currently have Ajax applications?

Monday, 22 Sep 2008 11:27 by Tobias Zimmergren
Thanks Daniel. TJSaynor; Thanks for pointing out the typo, it's fixed :)

Tuesday, 23 Sep 2008 08:52 by Dennis
.net 2.5 sounds interesting ;) Anyhow, looks easy enough to implement. how about making automatic? how can we use .net 3.5 in sharepoint in a good way. what do we win by doing so?

Tuesday, 23 Sep 2008 04:00 by Roger Persson
Testade precis att köra på web.config ändringarna. funkar kalasbra änsålänge. tack :)

Wednesday, 24 Sep 2008 09:26 by Sven Petersson
Ah! was looking in the web.config to find out how the heck i should do this and it was this easy hehe. thanks for your help and time, it's invaluable!

Friday, 26 Sep 2008 08:29 by Swedish SharePointer
if u could write about some linq stuff with sharepoint it would be really coool. and perhaps other things would be cool, like wcf, silverlight and stuff like that

Monday, 29 Sep 2008 02:34 by ted
cool. works nice

Tuesday, 30 Sep 2008 03:04 by Jeremy Thake
There is actually a codeplex project that you can download with a solution that has a feature to make the modifcations to the web.config. This is extremely useful when in a farm environment where thre are multiple web.configs. It also acts as a quick way to see whether it's been deployed to your Web Application within the Farm already. It's called the 3.5 Web Config Feature and is available here: http://www.codeplex.com/features/Release/ProjectReleases.aspx?ReleaseId=2502

Tuesday, 30 Sep 2008 06:33 by Tobias Zimmergren
Hey Jeremy, I noted that the Feature project at CodePlex has this auto-configuration tool as you mention. Sounds sweet. Will have to try it out for sure.

Sunday, 19 Oct 2008 05:58 by Clinton Ingram
Just FYI, your steps 1 and 7 are completely unnecessary in this case. All the system.webServer confiugrations (step 7) are used only by IIS 7 running in integrated pipeline mode, which is incompatible with SharePoint anyway. And Step 1 registers a bunch of configuration sections that you never used (except for the empty system.web.extensions section in Step 7)

Sunday, 19 Oct 2008 09:48 by Dave W
followed along and works good here with all the steps. shall try what clinton says too and see if it still works without the 1 and 7 step. either way, it works as planned and doesn't cause us any pain whatsoever to do all the steps. will update here if i get more info on the 1&7 removal. thanks for a good post.

Thursday, 18 Dec 2008 04:30 by Greg Farquhar
The System.webserver tags at step 7 seem to be duplicated. I could not get the feature project from codeplex to activate. So I endec up using the above. I still have a problem embedding a silverlight webpart. Something seems to be missing.

Thursday, 18 Dec 2008 06:01 by Greg Farquhar
Nope, I have managed it now. Thanks for your information

Thursday, 8 Jan 2009 10:52 by Gilly
Got here from Jan Tielens blog. Good simple explanation man.thx

Wednesday, 14 Jan 2009 06:42 by TweeZz
Hi, this post was very helpfull to me, but still... it is missing one web.config session. At least for my application. I don't want to get into details, but in order to make my sharepoint application work, I had to add the following section to my web.config file: It costed me (or better my employer) a bit more then 9 hours of googling and hair pulling to figure this out. Maybe you could add this to the list of necessary changes to web.config? Let me know if you want to know the details why apparently I needed this section (and you did not).. Manu.

Wednesday, 14 Jan 2009 06:43 by TweeZz
Hi, this post was very helpfull to me, but still... it is missing one web.config session. At least for my application. I don't want to get into details, but in order to make my sharepoint application work, I had to add the following section to my web.config file: It costed me (or better my employer) a bit more then 9 hours of googling and hair pulling to figure this out. Maybe you could add this to the list of necessary changes to web.config? Let me know if you want to know the details why apparently I needed this section (and you did not).. Manu.

Wednesday, 14 Jan 2009 06:47 by TweeZz
Hmm.. Or my piece of web.config did not come trough in the comment I just posted or I simply did not paste it there :) Anyway this is the piece I needed to add in my web.config to make everything function: Hope this might help other desperate people!

Tuesday, 27 Jan 2009 01:57 by David
Hi i have severals problems when i try to show a silverligth app in a sharepoint site. We try to use silverpart but there is an error about the silverligth plugin. I watched in this blogs some post about it but i can´t solve this problems. How can I start to show a silverligth app in a web part? Any ideas? Thanks

Wednesday, 11 Mar 2009 08:12 by Peter
Interesting post, it's going in my bookies for future reference!

Friday, 13 Mar 2009 02:15 by
this is greate help, better than the lazy way which is post by Jan:http://weblogs.asp.net/jan/archive/2008/10/10/enabling-net-3-5-in-sharepoint-2007-sites-the-lazy-way.aspx

Wednesday, 29 Apr 2009 04:26 by rpallothu
I used System.Xml.Linq and DocumentFormat.OpenXml dll to merge the office documents, which is working fine in 3.5 framework. When i bind my page with sharepoint site iam getting an exception saying 'System.Collections.Generic.IEnumerable' does not contain a definition for 'Last' at System.Web.Compilation.AssemblyBuilder.Compile() Code snippet: using (WordprocessingDocument myDoc = WordprocessingDocument.Open("Desc.docx", true)) { string altChunkId = "AltChunkId" + i; MainDocumentPart mainPart = myDoc.MainDocumentPart; AlternativeFormatImportPart chunk = mainPart.AddAlternativeFormatImportPart( AlternativeFormatImportPartType.WordprocessingML, altChunkId); using (FileStream fileStream = File.Open("Temp.docx", FileMode.Open)) chunk.FeedData(fileStream); AltChunk altChunk = new AltChunk(); altChunk.Id = altChunkId; mainPart.Document .Body.InsertAfter(altChunk, mainPart.Document.Body.Elements().Last()); mainPart.Document.Save(); } Note: when i change my applicaiton framework version to 3.0 also i am getting the same exception in my local, which i got in sharepoint. Is it mean that sharepoint doens't support 3.5 framework DLL.. Please advise.

Wednesday, 29 Apr 2009 06:55 by Tobias Zimmergren
rpallothu: Have you configured SharePoint to run under .NET 3.5?

Thursday, 30 Apr 2009 01:21 by rpallothu
No, i didn't Please help me to configure Sharepoint to run on .Net 3.5

Thursday, 30 Apr 2009 02:08 by Tobias Zimmergren
rpallothu: If you read this article from top to bottom, you should be able to do so. It's simply a matter of web.config modifications.

Thursday, 30 Apr 2009 05:27 by rpallothu
hi Tobians, I have done all 7 steps in my application config file.Still iam getting the same error. my code is using Sysytem.Xml.Linq methods. please advise

Name:
URL:
Email:
Comments: