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

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

Related

Core 2 error referencing Framework libraries

I have a test project int Core 2 console (Core2ConsoleTest).
It make a reference to .NET Framework 4.6.1 Project (NetFrameworkTest).
NetFrameworkTest project references the standard System.Printer.dll.
Download Core2ConsoleTest project here
When I call to any System.Printer function I have the error: Could not load file or assembly 'System.Printing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. El sistema no puede encontrar el archivo especificado.
I tested with other standard libraries like System.Windows.Forms.dll and the same error if the Core project references a Nuget Package that uses standard libraries.
Note: The same error with ASP.Net Core 2
Thanks for your help!
This is not going to work on .NET Core.
.NET Core 2.0 has a compatibility layer that allows loading and using .NET Framework libraries but this only works as long as this library only uses types and methods that are also available on .NET Core.
Since System.Printing is not part of .NET Core, this library will fail to access it with the exception you posted.
Only .NET Framework applications can use this API (e.g. an ASP.NET Core on .NET Framework application).
I really have the problem with ASP.Net Core Framework Project. I'm unable to create a new Project with Core 2.0 and reference a Framework library that references System.Printing.dll or other libraries.
But #mairaw gave me another way: On a project that works in Core 1.1, updating the libraries Nuget to 2.0, works correctly.
So it looks like a Visual Studio 2017 problem or Core templates.
My concern is to remove this functionality, because it allows to adopt the Core technology in a staggered way with a high code reuse.
Edit: Added sample projects
CoreTest.zip -> A ASP.Net Core Framework Project created referencing Core 1.1 and .NET Framework 4.6.1 in the past, then upgraded to Core 2.0 using Nuget: WORKS!
Core2Framework.zip -> A similar project (ASP.Net Core Framework Project created referencing Core 2.0) created with Visual Studio 2017 15.3.4: ERROR when calling System.Prinig.dll from the .NET Framework 4.6.1 Project.

Adding third party application dependency in visual studio 2012

In my application their is a requirement of .net framework 4.5 to run it properly on other machine.
How it is possible that when my application is being install then .net framework is installed automatically?
You can set in dependency by adding the reference of .Net 4.0 Framework.
Did you check it by making .dll of third party applcation and referenced to you active application?

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 ?

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

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

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