Click here to Skip to main content
Licence 
First Posted 8 Oct 2006
Views 35,609
Bookmarked 15 times

Access .NET assembly through SSIS (Script Component)

By | 8 Oct 2006 | Article
Here is some cool stuff to call .NET assembly from SSIS
 
Part of The SQL Zone sponsored by
See Also

Introduction

Hi All,

 

Here is some cool stuff to call .NET assembly from Script Component of SSIS.

Remember whenever we use “Script Component” while developing SSIS application, by default we get list of assembly on click of “Add Reference” from default path …Microsoft.NET\Framework\v2.0.50727, as shown below,

Sample screenshot

Now question is how to call any business logic (Included in .NET assembly) from Script Component…?

I would say put physically that assembly (Which needs to be referenced) at …Microsoft.NET\Framework\v2.0.50727. But I believe this would be just a work around not a proper solution.

What follows is another approach to accustom described functionality,

1.      Import “System.Reflection” assembly in Script Component

2.      Add assembly (Which need to be referenced) in GAC

3.      Write following code to call external assembly from your own Script Component of SSIS.

           

//Define variable of type [Assembly] 

Dim targetAssembly As [Assembly] = Nothing

//Load assembly named “CallBySSIS” from GAC into defined variable 

targetAssembly = [Assembly].LoadWithPartialName("CallBySSIS")

//Define variable which used to hold “Type” object

Dim targetType As Type

//Get specific class from assembly here “clsTest”

targetType = targetAssembly.GetType("CallBySSIS.clsTest")

//Define variable of type Object

Dim objClsTest As Object

//Get instance of “clsTest” into defined variable

objClsTest = targetType.InvokeMember("clsTest", BindingFlags.CreateInstance,   Nothing, Nothing, Nothing)

//Now you are free bird to call function of class “clsTest” named //“writeToFile(String strMessage)”

objClsTest.writeToFile("Colour Dataflow : " + ex.Message)

4.      Add “option Strict Off” on the top of script component; else compile time error for casting will occur.

I hope this article will save SSIS developers life, since it shows path how to use complex logic written previously.      

 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Malpani Amol

Web Developer

India India

Member

I am a .NET developer cum designer. I work for Zensar Technologies Ltd. Pune (INDIA), I consult, I develop, I debug and besides that I speak at conferences and user groups and I also write. I have written some articles on WCF, WF, SSIS, Compression decompression, CLR Store Procedure, SQL Server Reporting Services 2005, Extended grid and lot more to count.
Reach to me on:-a.malpani@zensar.com


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Generalfaster extraction and loading on SSIS. Pinmemberblackpower2k719:54 25 Apr '09  
QuestionAdding External Library PinmemberSith Kong3:15 27 Jun '08  
GeneralOther solution Pinmembervincent19768:13 3 Jan '07  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 8 Oct 2006
Article Copyright 2006 by Malpani Amol
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid