Problem to create assembly which depends on other dll's from SQL Server

I am developing an application in .Net but I need to access to some procedures in ASP.Net since SQL Server.
I have got it but i have problems to assembly the dll if it has dependencies of another dll's.I have read that if a dll need other dll it call it automatically but when I try to assembly my class in .NET there is the next error:

Create failed for SqlAssembly 'ClaseEjemplo'.

Assembly 'csyt.dal, version=0.0.0.0, culture=neutral, publickeytoken=null.' was not found in the SQL catalog. (.Net SqlClient Data Provider)

Nevertheless if I the class hasn't another dependencies it works.The class I am trying to assembly is ClaseEjemplo.If I try to use the procedure of other class "'csyt.dal" I have problems.If ClaseEjemplo hasn't dependencies it works perfectly!
My class ClaseEjemplo is:

using System;
using System.Collections.Generic;
using System.Text;
using Csyt.DAL;
using Csyt.Info;

namespace ClaseEjemplo
{
public class Class1
{
public static long devolucion()
{
AIAlarmaDB.TipoCondicion aux1 = new AIAlarmaDB.TipoCondicion();

AIAlarmaDB aux = new AIAlarmaDB();
aux1=aux.GetTipoCondicionById(1);
return aux1.Id;
}

}
}
Thanks in advance

[1288 byte] By [bambinor] at [2007-12-22]
# 1
DIdi you install the referenced asselmbly in the GAC ? Otherwise the framework can′t use it.

HTH, jens Suessmeyer.

http://www.sqlserver2005.de

JensSuessmeyer at 2007-8-30 > top of Msdn Tech,SQL Server,.NET Framework inside SQL Server...
# 2

The assembly I want to add from SQL Server is Csyt.DAL because I need to call a procedure of this dll but this dll use another dll like Csyt.Info.If I try to assembly directly Csyt.DAL i have the following error:

Assembly 'csyt.info, version=0.0.0.0, culture=neutral, publickeytoken=null.' was not found in the SQL catalog. (.Net SqlClient Data Provider)

If I try to assembly firstly Csyt.Info I have the following error:

Assembly 'system.web, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a.' was not found in the SQL catalog. (.Net SqlClient Data Provider)

And if I try to assembly this one I obtain the following error:

Assembly 'system.drawing, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a.' was not found in the SQL catalog.
Warning: The Microsoft .Net frameworks assembly 'system.web, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a, processorarchitecture=x86.' you are registering is not fully tested in SQL Server hosted environment. (.Net SqlClient Data Provider)

So my problem is that I don't know if I need to install something or not because there is no way to add the assembly I want.Nevertheless If I do the assembly of a dll which doesn't depends on another one everything is ok but I need to solve the problem because it is the case I need

I am starting with this things so sorry if I insist too much but I don't know what I can do.........

Thanks again

bambinor at 2007-8-30 > top of Msdn Tech,SQL Server,.NET Framework inside SQL Server...
# 3

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\<version>)

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.

VineetRao-Microsoft at 2007-8-30 > top of Msdn Tech,SQL Server,.NET Framework inside SQL Server...
# 4

Vineet,

If I run the command as you suggested I am getting a circular reference problem (see below). Is there a workaround?

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

with permission_set = unsafe

Warning: The Microsoft .Net frameworks assembly 'system.web, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a, processorarchitecture=x86.' you are registering is not fully tested in SQL Server hosted environment.

Warning: The Microsoft .Net frameworks assembly 'system.drawing, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a, processorarchitecture=msil.' you are registering is not fully tested in SQL Server hosted environment.

Warning: The Microsoft .Net frameworks assembly 'system.enterpriseservices, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a, processorarchitecture=x86.' you are registering is not fully tested in SQL Server hosted environment.

Warning: The Microsoft .Net frameworks assembly 'system.runtime.remoting, version=2.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089, processorarchitecture=msil.' you are registering is not fully tested in SQL Server hosted environment.

Msg 10300, Level 16, State 2, Line 1

Assembly 'System.Web' references assembly 'system.web, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a.', 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: version, culture or public key mismatch). Please load the referenced assembly into the current database and retry your request.

VladimirGaitanov at 2007-8-30 > top of Msdn Tech,SQL Server,.NET Framework inside SQL Server...

SQL Server

Site Classified