Monday, March 19, 2012

Creating a Picture in CLR?

I should want to be able to dynamic create a picture in SQL 2005. I have
looked at CLR and this look very intresstning but i can not import
System.Drawing into my project. Is it possible to do this in any way? The
dynamic picture will be returned in a SELECT so i need to use UDF.
/MartinWhy can't you do this in the client?
Adam Machanic
Pro SQL Server 2005, available now
http://www.apress.com/book/bookDisplay.html?bID=457
--
"Martin Josefsson" <Martin Josefsson@.discussions.microsoft.com> wrote in
message news:1E02A10D-4EDE-4593-B709-388DAF0D96C8@.microsoft.com...
>I should want to be able to dynamic create a picture in SQL 2005. I have
> looked at CLR and this look very intresstning but i can not import
> System.Drawing into my project. Is it possible to do this in any way? The
> dynamic picture will be returned in a SELECT so i need to use UDF.
> /Martin|||The client will be Crystal Reports XI and here i can not use a UDF that
returns a image. So what i can see is the only way to produce the image on
the Server.
/Martin
"Adam Machanic" wrote:

> Why can't you do this in the client?
>
> --
> Adam Machanic
> Pro SQL Server 2005, available now
> http://www.apress.com/book/bookDisplay.html?bID=457
> --
>
> "Martin Josefsson" <Martin Josefsson@.discussions.microsoft.com> wrote in
> message news:1E02A10D-4EDE-4593-B709-388DAF0D96C8@.microsoft.com...
>
>|||"examnotes" <Martin
Josefsson@.discussions.microsoft.com> wrote in
news:1E02A10D-4EDE-4593-B709-388DAF0D96C8@.microsoft.com:

> I should want to be able to dynamic create a picture in SQL 2005. I
> have looked at CLR and this look very intresstning but i can not
> import System.Drawing into my project. Is it possible to do this in
> any way? The dynamic picture will be returned in a SELECT so i need to
> use UDF.
>
The problem you are encountering is that System.Drawing is not part of
the "blessed" assemblies who are allowed to be loaded from the GAC; it
has to be loaded from the database. So what you need to do is to first
catalogue the System.Drawing assembly in the database through CREATE
ASSEMBLY. Then you should be able to use it.
HOWEVER!!! You probably have to create the assembly under the UNSAFE
permission set, which should tell uou that you should be really careful
with what you are doing. Just because you can do it in SQLCLR doesn't
mean it is a good idea!!
Niels
****************************************
**********
* Niels Berglund
* http://staff.develop.com/nielsb
* nielsb@.no-spam.develop.com
* "A First Look at SQL Server 2005 for Developers"
* http://www.awprofessional.com/title/0321180593
****************************************
**********|||>You probably have to create the assembly under the UNSAFE permission set
Read more about it...
http://blogs.msdn.com/tims/archive/.../27/142798.aspx

No comments:

Post a Comment