Lets imagine that we have two assemblies:
- Foo.Logic (compiled on .NET 2.0 framework)
- Foo.Application (compiled on .NET 4.0 framework) that have reference and uses compiled Foo.Logic.
Does it have impact on Foo.Application performance (or have any other drawbacks)?
In the situation you described in the question, everything will Just Work™ without any problems.
A .NET 4.0 application will load a .NET 2.0 library directly into the .NET 4.0 runtime environment. It will not use side-by-side execution unless you explicitly ask it to. There’s a lot of misinformation or unclear statements made about this around the web, so be careful in evaluating what you read.
I finally came across this article, which confirms what Jon Skeet says in his answer. In particular, the article explains (emphasis added):
But if you’re interested in even more of the nitty-gritty details, it’s worth mentioning that one of the new features introduced with version 4.0 of the CLR is the ability to run multiple versions of the runtime at the same time from in a single process. This is called “In Process Side-by-Side Execution” (or “Inproc SxS” if you’re very cool), and is a very powerful tool. You can read more about it here on the CLR team’s blog.
Here are some pretty pictures for demonstration purposes:
Note the “layer-cake” model that was used to build the .NET 3.0 and 3.5 releases on top of .NET 2.0. That means that they’ll all run side-by-side without any problems. But the isolation of the other versions will create a problem.
However, as mentioned above, .NET 4.0 solves this problem with Side-by-Side Execution:
Of course, this is mostly applicable to situations involving COM and interop with external applications like Outlook, but it’s still a very cool feature.
But either way, you shouldn’t see any problems whatsoever with this approach, either with compatibility, performance, or whatever else.