Solved

SQL SERVER 2005 Create Assembly

Posted on 2010-09-21
11
2,528 Views
Last Modified: 2012-05-10
Hi

I am trying to create an assembly in sql server 2005 so that I can use the functions inside the dll, This dll is working in production.

This is what I did and I got the following results after executing, Any inputs will be appreciated

Thanks

USE [XXXX]
GO
CREATE ASSEMBLY [Charge]
AUTHORIZATION [dbo]
FROM 'c:\WINDOWS\system32\Charge.dll'
WITH PERMISSION_SET = UNSAFE

Warning: The Microsoft .Net frameworks assembly 'system.xml.linq, version=3.5.0.0, culture=neutral, publickeytoken=b77a5c561934e089, processorarchitecture=msil.' you are registering is not fully tested in SQL Server hosted environment.
Warning: The Microsoft .Net frameworks assembly 'system.core, version=3.5.0.0, culture=neutral, publickeytoken=b77a5c561934e089, processorarchitecture=msil.' you are registering is not fully tested in SQL Server hosted environment.
Msg 10301, Level 16, State 1, Line 1
Assembly 'Charge' references assembly 'system.runtime.serialization, version=3.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089.', 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: 2(The system cannot find the file specified.)). Please load the referenced assembly into the current database and retry your request.
0
Comment
Question by:baylar
  • 7
  • 4
11 Comments
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33727825
This is what i found it on net


In order for SQL Server to use an assembly, the assembly and all its dependent assemblies must be stored inside SQL Server. When you create assembly, SQL Server tries to find load the assemblies the original assembly uses from the same directory.  

 

This means since your assembly uses the ManagedDTS assembly, and the ManagedDTS assembly uses Windows.Forms, Msxml6_interop, etc, you need to load all those assemblies into the system. Microsoft.SQLServer.msxml6_interop.dll is located in the GAC on your system. Most of the assemblies you will need are either in Framework directory or %WINDIR%\assembly. To speed things up, you will want run create assembly on any assembly you see in a warning message so that SQL will only load it once, and not try to reload it from disk subsequently.
0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33727839
check out this link also

http://support.microsoft.com/kb/922672
0
 

Author Comment

by:baylar
ID: 33731026
OK as per your instructions I ran the below but some new error, Can you please take a look…
I also tried with SAFE option but same thing.

CREATE ASSEMBLY [System.Core]
AUTHORIZATION [dbo]
FROM 'c:\WINDOWS\system32\System.Core.dll'
WITH PERMISSION_SET = unsafe

Warning: The Microsoft .Net frameworks assembly 'system.core, version=3.5.0.0, culture=neutral, publickeytoken=b77a5c561934e089, processorarchitecture=msil.' you are registering is not fully tested in SQL Server hosted environment.
Msg 10327, Level 14, State 1, Line 1
CREATE ASSEMBLY for assembly 'System.Core' failed because assembly 'System.Core' is not authorized for PERMISSION_SET = UNSAFE.  The assembly is authorized when either of the following is true: the database owner (DBO) has UNSAFE ASSEMBLY permission and the database has the TRUSTWORTHY database property on; or the assembly is signed with a certificate or an asymmetric key that has a corresponding login with UNSAFE ASSEMBLY permission. If you have restored or attached this database, make sure the database owner is mapped to the correct login on this server. If not, use sp_changedbowner to fix the problem.
0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33731862
0
 

Author Comment

by:baylar
ID: 33756910
HI
I think I am close...

Thanks for all your links, After altering database option TRUSTWORTHY to true I was able to do create assembly on some of the DLLs I was happy then until I reached a point where its keep on asking to register 'system.runtime.remoting’ while I was trying to register ‘system.enterpriseservices’ and vice-versa and I don’t know where to go from here

My whole intension is to use the methods of ‘Charge’ DLL from sql server in a way similar the frontend application is using to write to tables.


CREATE ASSEMBLY [system.enterpriseservices]
AUTHORIZATION [dbo]
FROM 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\system.enterpriseServices.dll'
WITH PERMISSION_SET = unsafe
GO

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.
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.
Msg 10300, Level 16, State 2, Line 1
Assembly 'System.EnterpriseServices' references assembly 'system.enterpriseservices, 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.


CREATE ASSEMBLY [system.runtime.remoting]
AUTHORIZATION [dbo]
FROM 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Runtime.Remoting.dll'
WITH PERMISSION_SET = unsafe
GO

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.
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.enterpriseservices, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a, processorarchitecture=x86.' you are registering is not fully tested in SQL Server hosted environment.
Msg 10300, Level 16, State 1, Line 1
Assembly 'System.Web' references assembly 'system.enterpriseservices, 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.

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33756985
Wil get back 2u tomorow morning
0
 
LVL 19

Accepted Solution

by:
Bhavesh Shah earned 500 total points
ID: 33764156

check out this one

http://social.msdn.microsoft.com/Forums/en-US/sqlnetfx/thread/2d32a1e4-96f6-4ade-8400-f9bb63cfc25f

here they saying

I just tried this exact same statement on my SQL Server 2005 SP2 installation and it worked fine. I am guessing that your .NET framework installation especially System.Web is corrupt since it is refering to itself. Can you try it on any other system or try re-installing the .NET framework,
0
 

Author Comment

by:baylar
ID: 33775422
Today I tried this on the production box but the same error, I ran all this on sql server 2005, with SP3,  I might need to contact the person who have written this dll, The last thing I will try is to re-install .NET framework and will let you know.

Anyways thanks for your help and support, If any success I will post back to this thread.
0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33775880
Dear author,
If last solution is also not workd out,i suggest that use Request attention Link,so higher level experts can giv their views.
0
 

Author Closing Comment

by:baylar
ID: 33827839
Thanks Brich you have come long way to help with this, Finally it worked.....

1. registered the System.Web.dll from the Framework64 directory
2. used unsafe option for my dll

Now I can see my dll under assembilies inside sqlserver, now I need to learn how to access that dll, do you have any suggestions
0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 33828001
Dear Author,

Pls create new Q for it.
So you can get solution very quickly
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now