2009-10-22 8 views
198

एक परियोजना है कि SlimDX इस्तेमाल किया परिवर्तित करने, और इसलिए, वहीं अप्रबंधित कोड है .NET 4.0 मैं निम्नलिखित त्रुटि का सामना करने के लिए:.NET 4 कॉन्फ़िगरेशन में 'useLegacyV2RuntimeActivationPolicy' क्या करता है?

Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

चारों ओर Googling मुझे समाधान, आवेदन config में जोड़ने के लिए है, जो दे दी है :, क्या है

<configuration> 
    <startup useLegacyV2RuntimeActivationPolicy="true"> 
    <supportedRuntime version="v4.0"/> 
    </startup> 
</configuration> 

मेरा प्रश्न है? मुझे इसके बारे में कोई दस्तावेज नहीं मिल रहा है।

उत्तर

155

थोड़ी देर के बाद (और अधिक खोज), मुझे जोमो फिशर द्वारा this blog entry मिला।

One of the recent problems we’ve seen is that, because of the support for side-by-side runtimes, .NET 4.0 has changed the way that it binds to older mixed-mode assemblies. These assemblies are, for example, those that are compiled from C++\CLI. Currently available DirectX assemblies are mixed mode. If you see a message like this then you know you have run into the issue:

Mixed mode assembly is built against version 'v1.1.4322' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

[Snip]

The good news for applications is that you have the option of falling back to .NET 2.0 era binding for these assemblies by setting an app.config flag like so:

<startup useLegacyV2RuntimeActivationPolicy="true"> 
    <supportedRuntime version="v4.0"/> 
</startup> 

तो ऐसा लगता है कि रनटाइम लोड मिश्रित मोड असेंबली बदल गया है। मुझे इस बदलाव के बारे में कोई जानकारी नहीं मिल रही है, या यह क्यों किया गया। लेकिन विशेषता वापस सीएलआर 2.0 लोडिंग पर वापस आती है।

+26

यह ध्यान देने योग्य है कि इस बीच मार्कलीओस उत्तर (http://stackoverflow.com/questions/1604663/what-does-uselegacyv2runtimeactivationpolicy-do-in-the-net-4-config/2467255#2467255) एक लिंक प्रदान करता है इस परिवर्तन के बारे में उनकी पूरी व्याख्या। –

+1

एमएसडीएन पर इसका एक संपूर्ण स्पष्टीकरण पाया जा सकता है (हालांकि यह ऊपर वर्णित समाधान का स्पष्ट रूप से उल्लेख नहीं करता है): http://msdn.microsoft.com/en-us/magazine/ee819091.aspx –

+0

क्या होगा यदि मैं ' मैंने इसे अपने एप्लिकेशन के लिए कॉन्फ़िगरेशन और मेरे यूनिटटेस्ट प्रोजेक्ट के लिए कॉन्फ़िगरेशन में जोड़ा है और परीक्षण चलते समय भी मुझे फ़ाइल लोड त्रुटि मिल रही है। क्या मुझे एक नया प्रश्न पोस्ट करना चाहिए? इस देर से अनुवर्ती के लिए – CodenameCain

116

यहां एक स्पष्टीकरण है जिसे मैंने हाल ही में लिखा है ताकि इस विशेषता पर जानकारी को रद्द करने में मदद मिल सके। http://www.marklio.com/marklio/PermaLink,guid,ecc34c3c-be44-4422-86b7-900900e451f9.aspx (इंटरनेट पुरालेख वेबैक मशीन लिंक)

सबसे अधिक प्रासंगिक बिट्स के शब्दों में:

[Installing .NET] v4 is “non-impactful”. It should not change the behavior of existing components when installed.

The useLegacyV2RuntimeActivationPolicy attribute basically lets you say, “I have some dependencies on the legacy shim APIs. Please make them work the way they used to with respect to the chosen runtime.”

Why don’t we make this the default behavior? You might argue that this behavior is more compatible, and makes porting code from previous versions much easier. If you’ll recall, this can’t be the default behavior because it would make installation of v4 impactful, which can break existing apps installed on your machine.

पूर्ण पोस्ट और अधिक विस्तार में इस बताते हैं। आरटीएम पर, इस पर एमएसडीएन दस्तावेज़ बेहतर होना चाहिए।

+10

+1, आपकी व्याख्या सबसे उपयोगी है! –

+0

सहमत हुए। वास्तव में बहुत अच्छी व्याख्या है। – Roman

+0

@ एचवीडी: जैसा कि मैं समझता हूं कि वेबैक मशीन बहुत भरोसेमंद है, क्या आप सीधे उत्तर के भीतर लिंक से संबंधित अनुभागों को उद्धृत करके इस उत्तर को और बेहतर कर सकते हैं? आपकी सहायताके लिए धन्यवाद! – BoltClock

संबंधित मुद्दे