I needed to create a CLR function to generate a report and uses ZedGraph to make a graph and save it on the disk.
I used VS 2005 to make the CLR function, but when try to add a reference to the project, all I see is few of the .Net assemblies, and there is no `Browse` button to add assemblies from the disk.
I did some google as usual and found this on Sql Server's Book Online:
Unsupported Libraries
Unsupported libraries can still be called from your managed stored procedures, triggers, user-defined functions, user-defined types, and user-defined aggregates. The unsupported library must first be registered in the SQL Server database, using the CREATE ASSEMBLY statement, before it can be used in your code. Any unsupported library that is registered and run on the server should be reviewed and tested for security and reliability.
And that solved the problem...
First, I'm not sure what Permission_Set ZedGrpah needs, so I'm going to mark the database as TrustWorthy so I can give the assembly an unsafe Permission_Set.
Use
Go
Alter
Then when I added the ZedGraph I got an error message:
Create
From
With
Msg 10301, Level 16, State 1, Line 1
Assembly 'ZedGraph' references assembly 'system.windows.forms, version=2.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089.', which is not present in the current database. SQL Server attempted to locate and automatically load the referenced assembly from the same location where referring assembly came from, but that operation has failed (reason: 2(The system cannot find the file specified.)). Please load the referenced assembly into the current database and retry your request.
So I did as it says, I added the System.Windows.Forms first
I noticed on the object explorer that the System.Windows.Forms was added with its refereces
Now add the ZedGraph
Now back to VS 2005
And everything goes well.
Important: Always add the unsupported assemblies from a query window, using CREATE ASSEMBLY command, do not add them using the Object Explorer, I tried it and it always gives error.
Remember Me
a@href@title, strike
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.