问题
I developed programs in C# .NET 4.0 using 3d-party libraries in .NET 4.0 and now I was asked to target a 3d-party program that has API only in .NET 1.1
I overlooked some previous discussions telling that it is impossible:
- MSDN .NET Framework Multi-Targeting Packs for Visual Studio 2010
- SO Can I still target .NET Framework 1.1 in VisualStudio 2010?
- etc.
This is weird that I cannot acsess previous .NET from a .NET (4.0).
The article:
- Working with .NET 1.1 in Visual Studio 2008 and Team Server
tells:
"here is how to use the latest IDE to work with a .NET 1.1 applications."
Is it applicable to VS2010 (and VS2012)?
What are the possibilities to target API in .NET 1.1 from .NET 4.0 (VS2010) project?
Inter-process communication?
Update:
@HighCore,
this is a program (terminal) providing access to Western trading stock exchange requiring login and cryptokeys for getting data over the internet and submitting orders (to buy, sell, etc.).
My program is algotrading bot in .NET 4.0 but the terminal is essentially to be also always used manually from Windows/GUI
I cannot get direct access to stock exchange or meddle with programs and libraries providing it :) or rather :(
Update2:
I do not even find .NET 1.1 on my Windows XP SP3 machine.
Windows update doesn't seen to get it.
I also recall that the last time I installed .NET 1.1 on it I had to reinstall thereafter VS2005, VS2008, VS2010 with Service Packs and all dependencides....
That is, my feeling is that it is necessary to install .NET 1.1 before later versions?..
回答1:
You need to change your app.config file:
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
The startup node must contain useLegacyV2RuntimeActivationPolicy="true".
回答2:
You can't directly. 1.1 runs on the 1.0+ CLR and this is not supported directly in VS2010+.
From the brief requirements you've mentioned, I would investigate some form of architectural/API boundary to compartmentalise the 1.1 API within 4+ CLR code if you can.
I'm pretty sure that you can't load the 1.1 CLR and the 4.0 CLR into the same process so, perhaps this will need you have some process separation.
If the 1.1 level code needs use your code, then you need to rewrite a version for that CLR and chances are it's not a trivial task due the great number of features in clr 2.0+ above 1.1. Again you need to define precisely what each side needs and isolate them appropriately. This is not something VS2010+ will do out of the box.
来源:https://stackoverflow.com/questions/15142836/what-can-i-do-to-target-api-in-net-1-1-from-net-4-0-vs2010-project