Showing posts with label book. Show all posts
Showing posts with label book. Show all posts

Tuesday, March 20, 2012

referencing system/CLR assemblies in SQLCLR

Throughout the course of this book and even before it I have come across conflicting information regarding how SQLCLR attempts to resolve system/CLR assembly references. For example, prior to my latest read thourgh April BOL 2005, I thought SQLCLR attempted to resolve these references implicity for you via the local machine's GAC. Yet here is what I found while trying to help another person in this forum yesterday in BOL...

Assembly Validation

SQL Server performs checks on the assembly binaries uploaded by the CREATE ASSEMBLY statement to guarantee the following:

The assembly binary is well formed with valid metadata and code segments, and the code segments have valid Microsoft Intermediate language (MSIL) instructions.

The set of system assemblies it references is one of the following supported assemblies in SQL Server: Microsoft.Visualbasic.dll, Mscorlib.dll, System.Data.dll, System.dll, System.Xml.dll, Microsoft.Visualc.dll, Custommarshallers.dll, System.Security.dll, System.Web.Services.dll, and System.Data.SqlXml.dll. Other system assemblies can be referenced, but they must be explicitly registered in the database.

For assemblies created by using SAFE or EXTERNAL ACCESS permission sets:

The assembly code should be type-safe. Type safety is established by running the common language runtime verifier against the assembly.

The assembly should not contain any static data members in its classes unless they are marked as read-only.

The classes in the assembly cannot contain finalizer methods.

The classes or methods of the assembly should be annotated only with allowed code attributes. For more information, see Custom Attributes for CLR Routines.

Besides the previous checks that are performed when CREATE ASSEMBLY executes, there are additional checks that are performed at execution time of the code in the assembly:

Calling certain Microsoft .NET Framework APIs that require a specific Code Access Permission may fail if the permission set of the assembly does not include that permission.

For SAFE and EXTERNAL_ACCESS assemblies, any attempt to call .NET Framework APIs that are annotated with certain HostProtectionAttributes will fail.

COULD SOMEONE PLEASE GIVE ME THE DEFENITE ANSWER ON HOW THIS WORKS!

And as a side note even if there is nothing more "to it" then these few lines in the CREATE ASSEMBLY topic in BOL, I think both this forum and the others prove that more information needs to be in BOL regarding this topic. How it relates to the subset of the .Net framework we have access to, HPAs, and CAS permissions.|||

Hi Derek,

Where have you found conflicting statements on the SQL CLR assembly loading process? If it's in BOL or in another MS reference, let me know or file a bug on connect.microsoft.com so it can be corrected.

The passage from BOL above is accurate: only the system assemblies on the "Supported .NET Framework Libraries" list can be implicitly referenced from the GAC; all others must be created explicitly through CREATE ASSEMBLY.

I think that CAS and HPA are also covered pretty thoroughly in BOL. "CLR Integration Code Access Security" describes all the permissions available under each permission set and you can use a tool such as PermView to see which ones are requested by your code. "Host Protection Attributes and CLR Integration Programming" provides the same treatment for HPAs, along with listing every class or method in the supported system assemblies that can't be used in SAFE or EXTERNAL_ACCESS.

Actually, I just noticed that "CLR Integration Programming Model Restrictions" does contain an error: the custom attributes it lists are not explicitly disallowed in the UNSAFE permission set (although they are still not recommended and may not work as expected). I'll file a bug to get this fixed.

Steven

Friday, March 9, 2012

Reference Book Needed

I'm a consultant with 20+ years of experience. With Crystal Report Writer,
I just sat down and starting playing with it to figure it out, but now I am
confronted with using SQL Reporting Services 2005.
It is definitely giving me a shot of humility because I am finding it the
most frustrating experience ever. I purchased a pretty good book written by
Brian Larson, but it is presented in a procedural format, and is not being
very helpful when I have something specific to accomplish. I'm also trying
to use the online help and newsgroups, but the process is painstakingly
slow.
My challenge of the moment is in constructing a date range expression, but I
am also stuck on the parameters of the format function. I loved Crystal in
that I could use the wizard to give me a jump start with the formatting, and
then could edit it into more advanced queries.
Can anyone offer any suggestions on where I could find a good SQL Reporting
Services reference? I'm open to anything at this point -- website, book,
notes scribbled on a napkin...I know what you mean about books with references instead of walking through
the procedures. I bought Hitchhiker's Guide to SQL Server 2000 Reporting
Services by Peter Blackburn, William R. Vaughn , because I've read some good
reviews about it, and I liked the title and SQL Server 2000 Reporting
Services Step by Step Book/cd Package by S Misner because it came cheap with
the other one. I think I bought them too late, as they focus on how to do
the things I already knew how to do, and the references are poor. But when I
go through them, I can find things that I didn't know. Out of the two, only
one has been updated, "SQL Server 2005 Reporting Services Step by Step" by
S. Misner.
http://www.amazon.co.uk/Server-2005-Reporting-Services-Step/dp/0735622507/sr=1-1/qid=1160306842/ref=sr_1_1/026-7617136-7864435?ie=UTF8&s=books
You might want to check any reviews for it first, as it seems to be a
beginner's book.
My main source of information about Reporting Services has been articles
written by William E. Pearson, III
http://www.databasejournal.com/article.php/1459531
I started reading his articles when I started working with RS in 2004, and
got most of the basics from him. The first tutorials are based on SQL Server
2000 and RS 2000, but the later ones are based on RS 2005. Most of what he
writes about the 2000 edition still holds for 2005, though, so they're not
entirely useless.
I also find Brian Welcker's blog "Direct Reports" usefull
http://blogs.msdn.com/bwelcker/default.aspx
And from his blog you find links to other good RS blogs like Tudor's weblog
(http://blogs.msdn.com/bwelcker/default.aspx) and Chris Hay's Sleazy Hacks
(very usefull, http://blogs.msdn.com/ChrisHays/)
But whenever I need help to find out how to do something, I use the RS news
group. I know there's a forum for it as well, but it wasn't very active when
I started working with RS, and it's hard to teach old dogs new tricks. A lot
of answers can be found in old ng posts, and if you can't find it, ask and
you might get an answer. It's slow, I know, but when you figure out the
basics and the differences from Crystal Reports, it gets better.
Kaisa M. Lindahl Lervik
"Cindy Mikeworth" <CindyMikeworth@.newsgroups.nospam> wrote in message
news:uXbqlNk6GHA.4496@.TK2MSFTNGP05.phx.gbl...
> I'm a consultant with 20+ years of experience. With Crystal Report
> Writer, I just sat down and starting playing with it to figure it out, but
> now I am confronted with using SQL Reporting Services 2005.
> It is definitely giving me a shot of humility because I am finding it the
> most frustrating experience ever. I purchased a pretty good book written
> by Brian Larson, but it is presented in a procedural format, and is not
> being very helpful when I have something specific to accomplish. I'm also
> trying to use the online help and newsgroups, but the process is
> painstakingly slow.
> My challenge of the moment is in constructing a date range expression, but
> I am also stuck on the parameters of the format function. I loved Crystal
> in that I could use the wizard to give me a jump start with the
> formatting, and then could edit it into more advanced queries.
> Can anyone offer any suggestions on where I could find a good SQL
> Reporting Services reference? I'm open to anything at this point --
> website, book, notes scribbled on a napkin...
>