2011-07-27 16 views
8

मैं सीधे डीएलएस से लिंक करना चाहता हूं जो संकलन/रनटाइम पर उपयोग किए जाते हैं। मेरा प्रोग्राम लेआउट यह है: कंसोल एक्स ने एक Winform डीएल लॉन्च किया। वह डीएल प्रदर्शन करने के लिए डीएलएस का एक समूह का उपयोग करता है। Appconfig Winform डीएल की परियोजना में स्थित है। कुछ पढ़ने के आधार पर, Winform dll गलत app.config की तलाश में है? मैं असेंबली का उपयोग कर अपने डीएल निष्पादित करने का इरादा रख रहा हूं। लोडफ्रॉम();app.config dependentAssembly काम नहीं कर रहे

मैं एक app.config फ़ाइल बनाया है और अनुभाग

<runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
      <assemblyIdentity name="CommonConversions" 
           publicKeyToken="null" 
           culture="neutral" /> 
      <codeBase version="1.0.0.0" 
         href="file://C://BMS_ACTD//bin//DX//Globals//CommonConversions.dll"/> 
     </dependentAssembly> 
     <dependentAssembly> 
      <assemblyIdentity name="GlobalConstants" 
           publicKeyToken="null" 
           culture="neutral" /> 
      <codeBase version="1.0.0.0" 
         href="file://C://BMS_ACTD//bin//DX//Globals//GlobalConstants.dll"/> 
     </dependentAssembly> 
     <dependentAssembly> 
      <assemblyIdentity name="MessageInstance" 
           publicKeyToken="null" 
           culture="neutral" /> 
      <codeBase version="1.0.0.0" 
         href="file://C://BMS_ACTD//bin//DX//Globals//MessageInstance.dll"/> 
     </dependentAssembly> 
     <dependentAssembly> 
      <assemblyIdentity name="MessageInterface" 
           publicKeyToken="null" 
           culture="neutral" /> 
      <codeBase version="1.0.0.0" 
         href="file://C://BMS_ACTD//bin//DX//Globals//MessageInterface.dll"/> 
     </dependentAssembly> 
     <dependentAssembly> 
      <assemblyIdentity name="ToolsInterface" 
           publicKeyToken="null" 
           culture="neutral" /> 
      <codeBase version="1.0.0.0" 
         href="file://C://BMS_ACTD//bin//DX//Globals//ToolsInterface.dll"/> 
     </dependentAssembly> 
    </assemblyBinding> 
</runtime> 

स्थान निश्चित रूप से सही है अंदर निम्नलिखित लाइनों गयी। डीएलएस का दृढ़ता से नाम नहीं दिया जाता है, इसलिए publicKeyToken = "null"। मेरे सभी संस्करण 1.0.0.0 हैं। जब मैं अपने संदर्भित डीएल के गुणों को देखता हूं, तो संस्कृति खाली होती है। क्या मेरा भी होना चाहिए? क्या ऐसा कुछ भी है जो ऐसा प्रतीत होता है कि मैं गलत कर रहा हूं?

+0

आपने क्या त्रुटि मिलता है? – oleksii

+0

प्रकार 'System.IO.FileNotFoundException' का एक पहला मौका अपवाद BmsReplayAnalysis.dll में हुई प्रकार 'System.TypeInitializationException' का एक पहला मौका अपवाद BmsReplayAnalysis.dll में हुई लोड नहीं कर सका फ़ाइल या विधानसभा 'MessageInterface, संस्करण = 1.0 .0.0, संस्कृति = तटस्थ, PublicKeyToken = शून्य 'या इसकी निर्भरताओं में से एक। सिस्टम – Jason

+0

निर्दिष्ट फ़ाइल नहीं ढूंढ सकता है क्या आप प्रश्न में अपनी स्पष्टीकरण जोड़ सकते हैं? –

उत्तर

3

App.config का उपयोग किसी डीएल पर नहीं किया जाना चाहिए बल्कि केवल निष्पादन योग्य के साथ किया जाना चाहिए।

आप एक निष्पादन के भीतर एक dll dll चल निष्पादन की कॉन्फ़िग फ़ाइल का उपयोग करेंगे लोड और config उसके लिए परिभाषित अनदेखी करेंगे तो ..

अगर आप चाहें तो आप उपयोग कर config की चाबी पढ़ सकते हैं कुछ बदसूरत कोड जो उन्हें वर्तमान असेंबली की कॉन्फ़िगरेशन फ़ाइल से ले जाता है ..

आपको क्या करना चाहिए exe config फ़ाइल में प्रासंगिक कॉन्फ़िगरेशन डालना है।

अद्यतन

मिले आगे निम्नलिखित प्रश्न में जानकारी: C# DLL config file

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