2010-02-21 11 views
7

Ho creato un assembly per l'integrazione CLR in SQL Server 2008. Ha un riferimento a System.Web.Extensions, che è un problema perché quando provo ad aggiungere il mio assembly, Viene visualizzato il seguente errore:Come fare riferimento agli assembly GAC quando si integra un'estensione CLR in SQL Server

Assembly 'system.web.extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35.' was not found in the SQL catalog. (Microsoft SQL Server, Error: 6503)

Come si ottiene SQL Server per fare riferimento all'assembly richiesto?

+0

cosa stai fa riferimento a System.Web.Extensions? –

+0

JavaScriptSerializer - ma va bene, ho appena scritto il mio parser JSON, eliminando così la necessità di fare riferimento a qualsiasi cosa :) –

+0

Sarebbe molto utile se apri il codice del tuo parser JSON. –

risposta

9

A quanto pare non può, in base alle this post sul Microsoft forum:

CLR integration in SQL Server 2005 supports only a subset of .NET framework libraries to be references and used inside SQL Server. These are:

  • CustomMarshalers
  • Microsoft.VisualBasic
  • Microsoft.VisualC
  • mscorlib
  • System
  • System.Configuration
  • System.Data
  • System.Data.OracleClient
  • System.Data.SqlXml
  • System.Deployment
  • System.Security
  • System.Transactions
  • System.Web.Services
  • System.Xml

These libraries have been tested to ensure they are reliable to run inside SQL Server. These libraries can be referenced in any code and do not have to be registered using CREATE ASSEMBLY. These are the only assemblies that SQL Server allows CLR to load from GAC. All other assemblies (within .NET framework or otherwise) need to be registered explicitly inside the database. Any code that is outside of these libraries should be tested well by the user for reliability and security.

While the assemblies you are trying to registered are not supported by CLR integration you can use them if you test your functionality well. An easy way to register system.web and all its dependencies is to register them from the .NET framework install directory (usually c:\windows\microsoft.net\framework\)

e.g:

CREATE ASSEMBLY SystemWeb from 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.dll'

with permission_set = unsafe

Since all the dependent assemblies are in the same directory, SQL Server would automatically register them.

Thanks,

-Vineet.

Problemi correlati