C#: Load referenced assembly based on framework version?
Is it possible to load a referenced assembly only if the .NET Framework version is lesser than a specific number ?
I'm using a selfmade LINQ library on .NET 2.0, but 开发者_JS百科if the framework is 3.5+, it should use the M$ LINQ library, and ignore the selfmade one.
Edit:
Here's my library: http://linq4you.codeplex.com/Yes, you can do that by modifying your project file.
Open your csproj file in a text-editor, and find the line in the project file that describes the dependency that you want to conditionally load, and make sure that it looks like this, for instance:
<Reference Include="LinqBridge" Condition="$(TargetFrameworkVersion)=='v2.0'">
<HintPath>..\..\..\DevSupport\Lib\LinqBridge\LinqBridge.dll</HintPath>
<Private>True</Private>
</Reference>
精彩评论