Is it possible to have single (portable?) library for .NET 3.5 and .NET 4.5? - sharepoint

We have a large project targeting SharePoint 2010/.NET 3.5 built against the SharePoint.dll and we plan to expand it to support SharePoint 2013 as well, but the new SharePoint uses SharePoint.dll compiled in .NET 4.5.
Is it possible to somehow share code between .NET 3.5 and .NET 4.5 projects, something like Portable Class Libraries, but between .NET 3.5 and 4.5? Or the only solution is starting new project for .NET 4.5 and using referenced files from the first .NET 3.5 project?

The .NET build target is per project, so a 4.5 solution can include a project library targetting 3.5. Your can have a 4.5 library that extends the 3.5 solution where required and your main solution can build to 4.5 and include the 4.5 library.
Thus both the 3.5 solution and the 4.5 solution use the same 3.5 SharePoint code library, but the 4.5 solution can extend your SharePoint library to take advantage of new features not available in 2010 and .Net 4.5

Related

How to find which version of RazorEngine works with which .net framework?

It am struggling to find out the simple information of which RazorEngine version works with which version of .net framework.
I am basically looking for the version that can work with .net core 2.2, but the dot net core version of Razor Engine (RazorEngine.NetCore 3.1.0) works only with .net core 3.1 and .net standard 2.0
I searched everything here https://github.com/Antaris/RazorEngine but could not find the .net core 2.2 compatible version of RazorEngine
Can anybody help?

Is there any advantage to a .NET Core library over .NET Standard library?

I'm porting my applications from VS2015 to VS2017 and trying to figure out the right migration path. I'm also moving my web services to .NET Core to take advantage of deploying to Linux or Windows servers. I see that I have the option of creating base libraries in .NET Standard or .NET Core. Is there any advantage to a .NET Core library or should I create the base libraries in .NET Standard by default?
Practically speaking, .NET Standard 2.0 is the intersection of .NET Framework 4.6.2(-ish) and .NET Core 2.0.
If you build a library targeting .NET Standard 2.0 then your library can be consumed by .NET Framework libraries and applications, as well as .NET Core libraries and applications. That's the advantage of Standard.
But there are several types/members that have been added to .NET Core which aren't part of .NET Standard. If you want to use something like the new CertificateRequest class you'd need to explicitly target .NET Core.
.NET Core allows new things to get to users faster than .NET Framework does, so the general tradeoff will always be ".NET Standard => more places; .NET Core => newer things".
.Net Standard is just package with interfaces with can be used to provide compatibility across .Net Framework, .Net Core and others
I wouldn't choose a .NET Core library. The differences are in the referenced libraries:
the .NET Standard library references the netstandardX.X NuGet meta-package
the .NET Core library references the netcoreappX.X NuGet meta-package
The netcoreapp package also includes some .NET Standard packages, but also a bunch of .NET Core App specific packages (including libuv. Don't know why a library needs libuv.)
So the .NET Standard library is for cross platform and the .NET Core library just for .NET Core

Inno Setup - Run InstallUtil from .Net 4.5 Location

Inno Setup provides variables for {dotnet35} and {dotnet40}, but I need to run the InstallUtil.exe program from something like {dotnet45}.
Is there a simple way to do this?
There is no such constant like {dotnet45} defined, however you can use the {dotnet40} constant, since .NET 4.5 is just an inplace upgrade for .NET 4.0. So, .NET 4.5 is in the same directory as .NET 4.0.
Related questions:
Where is the .NET Framework 4.5 directory ?
Where is .NET Framework 4.5 directory located ?

Can I use a .net 4.0 dll assembly reference in a .net 3.5 sharepoint web part?

I am using some dll's from the crm 2011 sdk in a .NET 3.5 web part.The target is for SharePoint 2010 online. When I try to build it gives me the following error:
The primary reference "microsoft.xrm.client" could not be resolved because it was built against the ".NETFramework,Version=v4.0" framework.
This is a higher version than the currently targeted framework ".NETFramework,Version=v3.5". VisualWebPartProjectWebServiceTest.
I cannot upgrade my web part to .NET 4.0 because SharePoint 2010 is not supporting .NET 4.0. Is there some other solution to reference .NET 4.0 dlls in a .NET 3.5 sharepoint webpart?
I will say NO, you can't use .Net framework 4.0 dll in 3.5 but Yes in the other way around. There are a few workarounds to achieve this, but in a little different way. Check these following SO posts for further reference:
Can you use a .NET 4.0 dll in a 3.5 project?
How Can i use .NET 4.0 code in C# project which is built using .NET framework 3.5?
Making a call to a .NET 4 library from 3.5

Can I use .NET 4 with SharePoint 2007?

I'm on a team that's currently building a MOSS 2007 based application (which relies on .NET 2), and we'd like to leverage the Entity Framework v4 (which relies on .NET 4).
Is this possible?
No. The 4.0 version of .NET has a new CLR (4.0) etc., but SharePoint 2007 is only supported on CLR 2.0.
Even SP2010 does not support .net 4.0 (yet).
Although I haven't tried, my guess is that it's not possible. In order to use .net 4.0 assemblies, the apppool running your moss site would have to be upgraded to the 4.0 version of asp.net. After that, version of system.web and other assemblies will change and I think that moss will simply stop working. But hey, it's just my guess. You can always try it out.
No. Even SharePoint 2010 is based on ASP.NET 3.5

Resources