Using the box api in SSIS
AnsweredDoes anyone have experience with scripting for box in SSIS?
I'm trying to get all the files in a certain folder by using a service account.
When doing this in a regular .Net project it runs without an issue,
but when trying the same thing in a script task (ssis package) it immediately
returns an error without running any code...
-
,
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
-
At long last I found a solution!
There are quite some steps to take,
- 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)
- Go to the folder were the package is stored and copy
- Place it in a new local/server folder
- Now you go to the ".csproj" file of your script task and copy the public keys for all your references
- then you have to update the references in your script task
- and then you need to update your ".csproj" file so that all dll's have their public keys once more
- 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.
-
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; }
Please sign in to leave a comment.
Comments
5 comments