Showing posts with label assembly. Show all posts
Showing posts with label assembly. Show all posts

Thursday, March 22, 2012

Error deploying managed stored proc

When I try to deploy this managed stored proc assembly on SQL Server 2005 I get this error:

Failed to initialize the Common Language Runtime (CLR) v2.0.50727 with HRESULT 0x8007000e. You may fix the problem and try again later

I looked on the net but found no documentation about it. I know the CLR v2.0 is working as I have some ASP.NET apps running from this server that use it. Any ideas?

Try the simple code to get a .dll file:

using System.Data;
using System.Data.SqlClient;
using Microsoft.SqlServer.Server;

public partial class StoredProcedures
{
[Microsoft.SqlServer.Server.SqlProcedure()]
public static void SampleSP(string connstring, out int spid)
{
using (SqlConnection conn = new SqlConnection(connstring))
{
conn.Open();

SqlCommand cmd = new SqlCommand("SELECT @.@.SPID", conn);
spid = (System.Int16)cmd.ExecuteScalar();
}
}
}

And then let's manually create assmebly from the dll file in Management Studio:

1. Login to SQL2005 as 'sa', locate a database->new query->execute following command:

alter database yourdb set trustworthy on

go

sp_configure 'clr enabled',1
reconfigure with override

go

2. create an assembly from the dll file

3. create a stored procedure which references the assembly:

create procedure testCLR @.conn nvarchar(max),@.i int output as
external name ClassLibrary2.[StoredProcedures].SampleSP

4. Test the procedure:

declare @.i int

exec testCLR 'Data Source=.;Integrated Security=SSPI;Database=master',@.i output

select @.i

And here is a good torturial for using CLR in SQL2005:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsql90/html/mandataaccess.asp

Sunday, February 26, 2012

Error connecting to .sdf database

Dear All,

I am trying to connect to a .sdf database. I am building a console application. First I got an error "Could not load file or assembly 'System.Data.SqlServerCe, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)". Then I manage to solve "Unable to load DLL 'sqlceme30.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)". So wat is the possible error on my side ?

Is it not amazing. I have been searching the forums for a solution to this specific problem for weeks now and everyone that answers has no idea what it is we are requesting. you get redirected to a thousand other sites that still can not answer this question. I dont think anyone knows how to solve this!

|||

Which version of the product are you using?

Checking the basics first: Is the product installed on your machine ( check in Add and remove programs).Also check that the System.Data.SqlServerCe.dll is in GAC (C:\windows\assembly).

If your installation was correct, then sqlceme30.dll (and other dlls) should be loaded automatically using some registry settings.

Btw, did you try reinstalling the runtime package on your machine?

Error connecting to .sdf database

Dear All,

I am trying to connect to a .sdf database. I am building a console application. First I got an error "Could not load file or assembly 'System.Data.SqlServerCe, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)". Then I manage to solve "Unable to load DLL 'sqlceme30.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)". So wat is the possible error on my side ?

Is it not amazing. I have been searching the forums for a solution to this specific problem for weeks now and everyone that answers has no idea what it is we are requesting. you get redirected to a thousand other sites that still can not answer this question. I dont think anyone knows how to solve this!

|||

Which version of the product are you using?

Checking the basics first: Is the product installed on your machine ( check in Add and remove programs).Also check that the System.Data.SqlServerCe.dll is in GAC (C:\windows\assembly).

If your installation was correct, then sqlceme30.dll (and other dlls) should be loaded automatically using some registry settings.

Btw, did you try reinstalling the runtime package on your machine?

Sunday, February 19, 2012

Error calling CreateReportHistorySnapshot method.

Hello,

I am getting an error when calling the CreateReportHistorySnapshot method from a custom assembly. The error is:

Response is not well-formed XML.

The data source is an XML file which is updated by the custom assembly before the call into the CreateReportHistorySnapshot method.

Has anyone seen this problem before or have any suggestions?

The Data Source XML is well-formed by the way... :-0)

I have had this error before when i wasnt the db admin. it seems there are a few errors along these lines where error messages flag up issues which are actually unrelated.

Try Permission and i would assume this will fix your error.

Andy

|||

Hi Andy,

Thanks for this!! Can you just clarify what would fix the error.

Many thanks.

|||

The user that is running the createsnapshot method needs to be set as the DB Owner within SQL, this fixed the same problem i was having with this a couple of months ago.

It is often the case with many of these areas, subcriptions is another area where db admin comes into play.

If you hear of another fix please let me know as this is not ideal for me as a long term solution.

Wednesday, February 15, 2012

Error adding Assembly to SQL 2005

I have a clr assembly that access the internet via Sockets and file access. This require me to set the Assembly permissions level to External.

There are lots of messages on the net regarding this issue. none have worked for me.

Currently I'm trying to install the assembly with "sign the assembly" checked, createing a strong name key file.

When I run the installation I get the following message from the server

"Create failed for SqlAssembly 'xxx'.(Microsoft.sqlServer.Smo)

an exception occured while executing a Transact-SQL statement or batch

(Microsoft.SqlServer.ConnectionInfo)

A severe error occured in the current command. The results, if any, should be discarded.

This is the messag I get.

The following link does not display any usefull information.

TITLE: Microsoft SQL Server Management Studio

Create failed for SqlAssembly 'KBTTriggers'. (Microsoft.SqlServer.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.1399.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+SqlAssembly&LinkId=20476


ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

A severe error occurred on the current command. The results, if any, should be discarded.
A severe error occurred on the current command. The results, if any, should be discarded. (Microsoft SQL Server, Error: 0)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=0&LinkId=20476


BUTTONS:

OK

Hi,

I am getting the same error. Anyone please help me out on this issue.

Thanks,

Arun

|||

I resolved this issue.

please refer the link for more details:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=194501&SiteID=1

Error adding Assembly to SQL 2005

I have a clr assembly that access the internet via Sockets and file access. This require me to set the Assembly permissions level to External.

There are lots of messages on the net regarding this issue. none have worked for me.

Currently I'm trying to install the assembly with "sign the assembly" checked, createing a strong name key file.

When I run the installation I get the following message from the server

"Create failed for SqlAssembly 'xxx'.(Microsoft.sqlServer.Smo)

an exception occured while executing a Transact-SQL statement or batch

(Microsoft.SqlServer.ConnectionInfo)

A severe error occured in the current command. The results, if any, should be discarded.

This is the messag I get.

The following link does not display any usefull information.

TITLE: Microsoft SQL Server Management Studio

Create failed for SqlAssembly 'KBTTriggers'. (Microsoft.SqlServer.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=9.00.1399.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+SqlAssembly&LinkId=20476


ADDITIONAL INFORMATION:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

A severe error occurred on the current command. The results, if any, should be discarded.
A severe error occurred on the current command. The results, if any, should be discarded. (Microsoft SQL Server, Error: 0)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=0&LinkId=20476


BUTTONS:

OK

Hi,

I am getting the same error. Anyone please help me out on this issue.

Thanks,

Arun

|||

I resolved this issue.

please refer the link for more details:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=194501&SiteID=1