November 12, 2008 at 7:52 am
I have a need to make a call to a com object from SQL. In SQL Server 2000 I was able to do this via the sp_OACreate, and sp_OAMethod procedures. I was hoping to be able to accomplish the same functionality using CLR, but I do not know if this is possible as I have run into a few issues.
1st Approach
I registerd my COM object in SQL Server using Create Assembly using the UNSAFE Permission level. I the created a CLR function, and tried to instantiate my COM Object and received a System.SystemSecurity exception.
2nd approach
I created a wrapper for my com object in .NET I then registered both the COM object and my wrapper assembly in SQL server using Create Assembly and UNSAFE perssion level. I then created a CLR function that calls a function from my wrapper assembly, but when the wrapper tries to instantiate the COM object i get a Invalid URI exception.
Is it possible to accomplish this task?
November 12, 2008 at 10:17 am
You are supposedly able to P/Invoke it in SQLCLR, but since I have never had a COM need in SQLCLR, I don't have experience to tell you exactly how that would be done. I can tell you from the MSDN Forums that people have reported the P/Invoke to be extremely slow with SQLCLR.
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1846574&SiteID=1
Jonathan Kehayias | Principal Consultant | MCM: SQL Server 2008
My Blog | Twitter | MVP Profile
Training | Consulting | Become a SQLskills Insider
Troubleshooting SQL Server: A Guide for Accidental DBAs[/url]
November 12, 2008 at 1:30 pm
And no matter what you do, it will definitely still be UNSAFE.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply