Welcome to the new Box Support website. Check out all the details here on what’s changed.

Using the box api in SSIS

Answered
New post

Comments

5 comments

  • jcleblanc

    ,

     

    Since you mentioned that an error is coming back before running any code, it may be best to pose the question on the SSIS forums since the error doesn't sound like it's coming from Box. If that's not the case please let me know, and if you could provide the entire Box API error we can see what we can do.

     

    Thanks,

    Jon

    0
    Comment actions Permalink
  • Dorien-

    At long last I found a solution! 

    There are quite some steps to take, 

     

    1. Install the "Box.V2" package via Nuget (so that you'll get the latest stable version of Box.V2 and the other resources that are necessary)
    2. Go to the folder were the package is stored and copy
    3. Place it in a new local/server folder
    4. Now you go to the ".csproj" file of your script task and copy the public keys for all your references
    5. then you have to update the references in your script task 
    6. and then you need to update your ".csproj" file so that all dll's have their public keys once more
    7. Lastly you have to put all the dll's in the GAC

    Just one more thing! Do all the above steps without closing your script task, 'cause the dll's are stored in a temporary folder.

     

     

    0
    Comment actions Permalink
  • dxh212

    Hi ,

     

    Have you tried dynamic loading or reflection to load the dlls at run time? This is what I'm researching now because I don't have the option of registering the dlls in the GAC..

     

    Thanks,

     

    Dennis

    0
    Comment actions Permalink
  • Dorien-

    Hi ,

     

    I'm sorry that my solution doesn't work for you.

    I haven't tried dynamic loading so I can't help you there...

     

     

     

    0
    Comment actions Permalink
  • dxh212

    Hi  ,

     

    I was able to resolve my issue utilizing the method described at https://cultivatingsoftware.wordpress.com/2018/08/21/ssis-load-dll-gac/

     

    public ScriptMain()
    {
        AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
    }

     

    I store all the assemblies required by the Box API in the same folder and in the resolve handler use reflection to load each one.

     

            private Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
            {
                try
                {
                    string path = @"D:\Box Automation Libraries\";
    
                    if (args.Name.Contains("Box.V2"))
                    {
                        return System.Reflection.Assembly.LoadFile(System.IO.Path.Combine(path, "Box.V2.dll"));
                    }
                    else if (args.Name.Contains("Newtonsoft.Json"))
                    {
                        return System.Reflection.Assembly.LoadFile(System.IO.Path.Combine(path, "Newtonsoft.Json.dll"));
                    }
                    else if (args.Name.Contains("Microsoft.IdentityModel.Logging"))
                    {
                        return System.Reflection.Assembly.LoadFile(System.IO.Path.Combine(path, "Microsoft.IdentityModel.Logging.dll"));
                    }
                    else if (args.Name.Contains("Microsoft.IdentityModel.JsonWebTokens"))
                    {
                        return System.Reflection.Assembly.LoadFile(System.IO.Path.Combine(path, "Microsoft.IdentityModel.JsonWebTokens.dll"));
                    }
                    else if (args.Name.Contains("Microsoft.IdentityModel.Tokens"))
                    {
                        return System.Reflection.Assembly.LoadFile(System.IO.Path.Combine(path, "Microsoft.IdentityModel.Tokens.dll"));
                    }
                    else if (args.Name.Contains("BouncyCastle.Crypto"))
                    {
                        return System.Reflection.Assembly.LoadFile(System.IO.Path.Combine(path, "BouncyCastle.Crypto.dll"));
                    }
                    else if (args.Name.Contains("System.IdentityModel.Tokens.Jwt"))
                    {
                        return System.Reflection.Assembly.LoadFile(System.IO.Path.Combine(path, "System.IdentityModel.Tokens.Jwt.dll"));
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                return null;
            }

     

    0
    Comment actions Permalink

Please sign in to leave a comment.