2014-09-04 7 views
5

मैं अपने पद ऐड में Microsoft.Bcl.Async उपयोग कर रहा हूँ के लिए काम करते हैं, मेरी ऐडइन में exe (test_addin.exe) फ़ाइल के रूप में संकलित किया गया है, कि माइक्रोसॉफ्ट वर्ड से एक विधानसभा के रूप में भरी हुई है, जब मैं निष्पादन सीधे शुरू करते हैं, सब कुछ ठीक काम कर रहा है, लेकिन जब मैं पद से चलाने, मैं कह रही है कि यह Systems.Threading.Tasks विधानसभा लोड करने में विफल एक त्रुटि हो रही है।बनाना बाध्यकारी रीडायरेक्ट कार्यालय ऐड-इन्स

Could not load file or assembly System.Threading.Tasks... 

ऐसा लगता है कि बाध्यकारी रीडायरेक्ट करने के लिए इससे संबंधित, जब मैं पद से आवेदन चलाने का प्रयास यह उम्मीद कॉन्फ़िग फ़ाइल 'C:\Program Files (x86)\Microsoft Office\Office15' फ़ोल्डर में स्थित हो सकता है और WINWORD.exe.config नाम दिया लग रहा है, कि दुर्भाग्य से असंभव है, क्योंकि मैं हो सकता है कि उस फ़ोल्डर तक पहुंच न हो।

मेरे test_addin.exe.config फ़ाइल:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <startup> 
     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" /> 
    </startup> 
    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-2.6.9.0" newVersion="2.6.9.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-2.6.9.0" newVersion="2.6.9.0" /> 
     </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 
</configuration> 

मैं सही पथ को इंगित करने के AppDomain.CurrentDomain.SetupInformation.ConfigurationFile स्थापित करने की कोशिश की है, लेकिन यह मदद करने के लिए प्रतीत नहीं होता है, वहाँ यह एक के लिए काम करने के लिए अन्य तरीके हैं कार्यालय ऐड-इन?

उत्तर

3

मैं एक कस्टम AssemblyResolve हैंडलर

Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs e) 
    { 
     try 
     { 
      if (!e.Name.ToLower().StartsWith("system.threading.tasks")) 
       return null; 

      AddoDebug.Instance.WriteLine("Assembly_Resolve"); 
      var assemblyDetail = e.Name.Split(','); 
      var assemblyBasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); 
      var assembly = Assembly.LoadFrom(assemblyBasePath + @"\" + assemblyDetail[0] + ".dll"); 

      return assembly; 
     } 
     catch (Exception ex) 
     { 
      AddoDebug.Instance.WriteLine("An exception occurred: " + ex, ADDOTraceStatus.Exception); 
      return null; 
     } 
    } 

को लागू करने से इस समस्या का समाधान कर लिया है लेकिन मुझे यकीन है कि यह एक अच्छा समाधान है नहीं कर रहा हूँ, इसलिए मैं इस सवाल का नया जवाब के लिए खुला छोड़ रहा हूँ।

+0

आप अपने कोड में यह जोड़ा है? – SsjCosty

+1

AppDomain.AssemblyResolve घटना की सदस्यता लें। – animaonline

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