Share via


Enabling .NET Framework 4.5 on LightSwitch Server Projects

With LightSwitch in Visual Studio 2012 (a.k.a LightSwitch V2) your server projects target the .NET Framework 4.0. This was a conscious decision on the team’s part in order to allow V2 applications to be deployed to the same servers running V1 applications with no fuss. Additionally the LightSwitch runtime takes no dependency on .NET 4.5, just 4.0.

That said, you may want to take advantage of some enhancements in .NET 4.5 on the server side so here’s how you can do that. Keep in mind that this not “officially” supported. The team has not fully tested this scenario so your mileage may vary. In order to change the target framework in LightSwitch, you need to modify the server project file.

Here are the steps:

  1. Close Visual Studio if you have your LightSwitch solution open
  2. Navigate to your solution’s \Server folder
  3. Edit the Server.vbproj (or csproj) file in a text editor like Notepad
  4. Make the following change to the <TargetFrameworkVersion>: <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
  5. Save the file & reopen Visual Studio
  6. Compile & verify no errors

Now you will be able to take advantage of the new features in .NET 4.5. For more info see: What's New in the .NET Framework 4.5. Keep in mind you will need to deploy to a server that supports .NET 4.5. See the “Supported Server Operating Systems” section of .NET Framework System Requirements.

Enjoy!

Comments

  • Anonymous
    January 23, 2013
    Ooooh Beth started "Hacking LightSwitch"...  Moahahahahahehehe he he cough  cough  (evil laughter during a cold winter).Thanks for the hint, and keep rocking LS like only you can! :-)Jan

  • Anonymous
    January 24, 2013
    @Jan - LOL! Actually folks have been asking for this in the forums and uservoice so I thought I would show them a workaround. (As you know) LightSwitch project properties do not let you change the framework within the IDE, but in the end, LS project files are just VS project files that have the same settings inside (+ more).

  • Anonymous
    July 21, 2013
    @BethDo you have a documentation on this? I couldn't find anything on this.

  • Anonymous
    July 24, 2013
    I thought I would show them a workaround

  • Anonymous
    July 25, 2013
    Its very good :)

  • Anonymous
    July 25, 2013
    Thats fantastic

  • Anonymous
    September 02, 2013
    If you develop an extension and require a reference to Microsoft.LightSwitch.Design.Designer, you will need to switch the server to 4.5 since the projects in the extension will require to be built for 4.5.Here's the error you get otherwise:The primary reference "Microsoft.LightSwitch.Design.Designer, Version=11.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the assembly "Microsoft.LightSwitch.Design.Core, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which was built against the ".NETFramework,Version=v4.5" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.0".You can repro this error with the sample available here:code.msdn.microsoft.com/.../SourceCode

  • Anonymous
    November 29, 2013
    Just encountered a weird issue, even though I updated the TargetFrameworkVersion of my assembly it was still running in a 4.0 Runtime.  I opened web.config and had to add       targetFramework="4.5" to the already existing httpRuntime node there, then all worked well again.Keep hacking LS! ;-)

  • Anonymous
    December 06, 2013
    @Myself (and others): forget about that node in the web.config unless you want to run into trouble with the built-in SqlMembershipProvider when deploying on Azure...

  • Anonymous
    June 07, 2015
    I thought I would show them a workaround

  • Anonymous
    January 22, 2016
    Just encountered a weird issue, even though I updated the TargetFrameworkVersion of my assembly it was still running in a 4.0 Runtime.