MOSS does .NET 3.5 Surprisingly Well

I’m sure that a lot of you guys out there are smarter than me and laugh at me writing this.


MOSS does .NET 3.5 without any worries! It works as good as you could possibly hope for – I expected it not to 😉

My experience is hampering me here, as I remember all the problems we had with .NET 2.0 for WSSv2 and/or SPS 2003 (hint: One of the two works) that effectively resulted in us staying with version 1.1 far longer than anyone wanted (same thing happened with the shift from 1.0). The average developer usually want to switch to the right around the beta 2 comes out (don’t we ever get smarter?).

I just wished somebody had written it plainly sooner so I wouldn’t have to go through the hoops myself and we could have started to use .NET 3.5 much sooner.

It is slightly curious how this works though. In the IIS management your SharePoint site (or any plain ASP.NET web application) that you want to use .NET 3.5 in should be set to “ASP.NET 2.0.xx” mode – there is no 3.0/3.5 mode. They really should re-label the option in IIS to something less confusing (I haven’t checked how it’s labeled in IIS7).

How can this be? It’s been a while since I did compiler design courses (I had the “tiger” book) but I can still give some educated guesses:

  • The CLR is unchanged between 2.0, 3.0 and 3.5.
  • Lambda expressions and Linq are handled at compile time so the actual MSIL code are unchanged along with some new libraries – in my younger days we used to call it “syntactic sugar”
  • .NET already knows how to link to libraries of dihfferent versions, provided that they use the same version of the CLR (as far as I know there are three 1.0, 1.1 and 2.0 plus some beta versions in between). Your .NET 3.5 code will use the libraries associated with that version of .NET and the .NET 2.0 code will use its own libraries – the w3wp process that runs both the .NET 2.0 and 3.5 code (as the MOSS site will do) therefore loads both the 2.0 and 3.5 libraries as needed.

I apologize to everyone who already knew this and thinks it obviously should just work. You may be smarter or less experienced/pessimistic (is there a difference?)


About Søren Nielsen
Long time SharePoint Consultant.

5 Responses to MOSS does .NET 3.5 Surprisingly Well

  1. Garth says:

    Thanks for this write up. Looking to put .net 3.5 on the Production servers and am reading around about it.

    Have you put .net 3.5 on any Production Servers?
    Have had any issues?


  2. Søren Nielsen says:

    Yes we did put it into production.

    Worked like a charm 🙂

    No issues at all.

    I’m told that you should be a bit careful if you used the Ajax stuff in 2.0 as that has changed substantially. I believe you need to upgrade those webparts by changing the code.

  3. rpallothu says:

    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 application 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))
    AltChunk altChunk = new AltChunk();
    altChunk.Id = altChunkId;
    .Body.InsertAfter(altChunk, mainPart.Document.Body.Elements().Last());


    Note: when i change my applicaiton framework version to 3.0 also i am getting the same exception in my local, what i got in sharepoint.

    Is it mean that sharepoint doens’t support 3.5 framework DLL..

    Please advise.

  4. rpallothu: I don’t believe SharePoint is to blame here.

    My guess is that your SharePoint server does not have 3.5 properly installed.

    Stuff to try:
    1. It works on you local machine from a web application, right? (As opposed to a console app). If not, convert it to a web app.

    2. Create a brand new web app on your sharepoint server (the app should not be a sharepoint one) and install your app there. Does it work? My guess would be no. If not then you have a problem with your 3.5 installation.

    3. Finally try again in SharePoint and hope for a differenc e;-)

    Good luck

  5. decatec says:

    even .NET 4.0 beta on MOSS-Sharepoint does work

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: