I'm getting this error..
Assembly
'microsoft.visualstudio.sourcesafe.interop, version=5.2.0.0,
culture=neutral, publickeytoken=b03f5f7f11d50a3a.' was not found in the
SQL catalog.
I added reference to VSS dll by opening the project file in notepad, as I couldn't right-click and do an add reference.
Here's the code...
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using Microsoft.VisualStudio.SourceSafe.Interop;
public partial class StoredProcedures
{
[Microsoft.SqlServer.Server.SqlProcedure]
public static void PrintToday()
{
try
{
//'— The SourceSafe INI file.
string iniVssPath = "C:/CLRVSS";
//'— The SourceSafe User ID/Password.
string cVSSUserName = "Admin";
string cVSSPassword = "";
VSSDatabaseClass vssLib = null;
vssLib = new VSSDatabaseClass();
vssLib.Open(iniVssPath, cVSSUserName, cVSSPassword);
VSSItem VSS_Item = vssLib.get_VSSItem("$/Test", false);
VSS_Item.Destroy();
SqlPipe p;
p = SqlContext.Pipe;
p.Send("success");
}
catch
{
SqlPipe p;
p = SqlContext.Pipe;
p.Send("error");
}
}
};
from BOL 2005 (April), CREATE ASSEMBLY (Transact-SQL):
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.
|||
Visual Studio does not automatically register all references. That is the reason you are not allowed to add arbitrary references to your SQL Server project. You can add references to only supported .NET framework assemblies or assemblies that are already registered in the database.
What you need to do in this case - Register the assembly you want to refer in the database and then add a reference to it.
Thanks,
-Vineet.
No comments:
Post a Comment