.NET 4 side by side problem - .net-4.0

If the host program is compiled with .NET 4, but a referenced dll is .net 3.5.
Then the target deploy machine need to install both .net 4 framework and .net 3.5 framework runtime?

No, in this case the target machine needs only the 4.0 framework runtime.

Related

Does .net framework 3.5 required to install .net framework 4.0?

I'm not cleared in the specification of .NET Framework 4.0. As per my knowledge .net framework 3.0 required .net framework 2.0 and .net framework 3.5 required .net framework 3.0, so I'm not cleared that whether .net framework 4.0 required .net framework 3.5? Whether .net framework 4.0 is standalone or not? I had searched most of the Microsoft helpful sites, but not got anything on that topic. Guys, If you know anything please share.
No, every version of .NET has been standalone. You can install .NET 3.0 with no other version installed, ditto .NET 3.5, ditto 4.0, ditto 4.5 etc.
Now there have been fewer versions of the CLR than there have of the .NET framework overall, but that's a different matter - and doesn't change whether or not you can install .NET without installing anything else.
Likewise some versions of .NET effectively install over the top of others (installing .NET 4.5 when you've got .NET 4.0 installed replaces the .NET 4.0 libraries) but you can still install each version without installing anything else first.

Accessing the .Net 4.0 Com from .Net 1.1 Project [duplicate]

I have external .net library compiled with .net framework 4 (it's provider moved recently to .net 4)
My code currently runs on .net framework 3.5
How to use that external library in my application ?
Moving whole application to .net 4 needs time and testing, so maybe in a future i will do that, but now, what are the possibilities ?
There are no possibilities, the CLR version that comes with .NET 3.5 cannot load 4.0 assemblies. The metadata format was changed. You have to force your app to use the .NET 4.0 CLR version. Do so by recompiling it with VS2010, targeting 4.0, or by using a .config file that contains the <requestedRuntime> element to ask for "v4.0".
Compatibility for .NET 4.0 is excellent btw.
While you cannot load the .Net DLL directly, you can wrap it in a COM interface, and load that COM interface in your .Net 3.5 process.
See Using a .NET 4 Based DLL From a .NET 2 Based Application
For more background information, Microsoft originally added In-Process Side-by-Side in .Net 4 to better support the scenario where an application loads add-ins via COM, and the add-ins were written with various versions of .Net. The ability to load .Net 4 DLLs in a .Net 3.5 process is just a nice side effect of that.

Using a .NET 4.0 DLL in Unity3d via COM/SxS?

In an attempt to oversimplify my issue, I'll try to keep it short:
I'm using the pro version of Unity, and I have 2 DLLs:
A .NET 3.5 assembly (acting as a COM client)
A .NET 4.0 assembly (with an interface exposed via COM)
The 3.5 uses COM to work with the 4.0. Using the 3.5 assembly in a Windows app works fine, it loads the 4.0 dll using SxS via Type.GetTypeFromCLSID() or Type.GetTypeFromProgID() (which I've confirmed with SxStrace), and can use it's functionality just fine. (The windows app mentions it's dependency on the 4.0 DLL via a manifest, I'm not registering the COM DLL.)
I'm trying to use the .NET 4.0 DLL in Unity. Obviously I can't use it directly, since the current flavor of Mono that Unity uses only supports up to 3.5, thus I created the 3.5 assembly to be my middleman. I'm able to use the 3.5 assembly fine in unity, but either of the Type methods I mentioned before throw NotImplementedException(s), as apparently they aren't supported by Unity (or rather, Mono), so I'm at a loss.
Any ideas?
Although this question was made 1 year ago..sadly the middleman tactic still wont work, it is not possible to use .NET 4.0 dlls within Unity3D since Mono is just not supporting the dependencies.
You could try to remove any 4.0 dependencies from the dll and compile it as 3.5, if that is possible for you.

Is there a way for a managed dll to call functions in a managed COM server?

I have a .net 3.5 dll and a .net 4.0 dll. The .net 3.5 dll need to call some functions in the .net 4.0 dll. To do this, I made the 4.0 .net dll as a COM server. However, I cannot tlbimp the tlb file exported from the 4.0 dll. Is it possible for a .net dll to call functions from a .net COM server? Thanks.
If possible you should either upgrade the 3.5 to 4.0 or downgrade the 4.0 to 3.5/2.0, so you can properly add the managed reference.
If you can't do that the alternative is to copy the declaration and replace [ComVisible(true)] by [ComImport] - however this may fail with a typecast exception on runtimes earlier than 4.0. I don't know if it works when 3.5 talks to 4.0, you'd have to test.

Can VS2010 project targeted to .NET 3.5 be released to .NET 4.0 only machine

I am tasked with requirements for the production machine (Server 2008 R2), and am wondering if this project setup would work with only .NET 4.0 installed and IIS 7 for WCF Service. Is .NET 3.5 needed to load assemblies that that are targeted to it?
A VS2010 solution contains several projects:
Projects targeted to .NET 3.5:
Model (DTO) classes
Business Logic Layer
Data Access Layer
Interfaces for BLL and DAL
Projects targeted to .NET 4.0:
WCF Service project wrapping BLL methods
In development, there's 2.0, 3.5 and 4.0 installed on the machine and everything works fine with WCF hosted in IIS6.0
By default, Server 2008 R2 comes with .Net Framework v2.0.50727 installed but you can install the .NET 3.5 Sp1 using: Server Manager -> Features -> .Net Framework 3.5.1 Features. I think .NET 4.0 Client is not enough to run your BLL if it's compiled with .NET 3.5
In case anyone else runs in to the same issue:
.NET 3.5 isn't required as the released DLLs run just fine with only .NET2 and .NET4 installed.
WCF Service targeted to .NET4 runs OK under IIS 7.0 with no modification or special configuration.