Automated deployment of mixed SSIS / DLL solution

后端 未结 4 1469
南旧
南旧 2021-02-15 12:49

We currently have a solution developed using SSIS / C#. The SSIS package (amongst other things) has a script task that uses logic developed in the class libraries. This function

4条回答
  •  醉酒成梦
    2021-02-15 13:18

    In my case, just calling Assembly.LoadFile didn't work. What did work was this approach:

    Call this in the class constructor:

    AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
    

    And then have this method, with all the dlls you need:

     private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
     {
         if (args.Name.Contains("libName.dll"))
             return Assembly.LoadFile(System.IO.Path.Combine(_libraryFolder, "libName.dll"));
    
         if (args.Name.Contains("libName2.dll"))
             return Assembly.LoadFile(System.IO.Path.Combine(_libraryFolder, "libName2.dll"));
    
         return null;
     }
    

    If they are a lot, you may want to refactor that with a List.

提交回复
热议问题