Hi,
when deploying assembly from VS into SQL Server 2005, deployment fails with these error messages:
Msg 0, Level 11, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
Msg 0, Level 20, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
I'm deploying assembly with UNSAFE permission setting.
What's wrong, please?
Thanx, Fipil
Can you:
1. Post or describe your code?
2. See if the same error happens when you run CREATE ASSEMBLY, CREATE FUNCTION etc. in Management Studio, rather than deploying through Visual Studio?
3. Is this on SQL Server/VS RTM, or CTP builds? OS and processor architecture?
Thanks|||
1. Here is my code
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Security.Cryptography;
using System.Security.Cryptography.Pkcs;
using System.Security.Cryptography.X509Certificates;
using System.Text;
public partial class UserDefinedFunctions
{
[Microsoft.SqlServer.Server.SqlFunction]
public static SqlString GetRandomPassword()
{
Random rnd=new Random();
string guid=Guid.NewGuid().ToString();
string pass = "";
for (int i = 0; i < 20; i++)
{
pass += guid[rnd.Next(guid.Length)];
}
return new SqlString(pass);
}
[Microsoft.SqlServer.Server.SqlFunction]
public static SqlBinary EncryptToken(string loginName, string password, byte[] bCert)
{
X509Certificate2 cert = new X509Certificate2(bCert);
string token = string.Format("{0};{1};{2}", loginName, password, cert.Thumbprint);
return new SqlBinary(encryptByCertPBK(cert,token));
}
private static byte[] encryptByCertPBK(X509Certificate2 cert, string msg)
{
Console.Write("Encrypting '{0}'... ", msg);
RSACryptoServiceProvider rsa = (RSACryptoServiceProvider)cert.PublicKey.Key;
byte[] textBytes = Encoding.UTF8.GetBytes(msg);
byte[] reth = rsa.Encrypt(textBytes, false);
Console.WriteLine("Done.");
return reth;
}
};
2. YES, the same error happens when I run CREATE ASSEMBLY in Management Studio:
CREATE ASSEMBLY DbTisSecurity
FROM 'D:\Test\DbFunctions.dll'
WITH PERMISSION_SET=UNSAFE;
3. I'm using the SQL Server 2005, Developer Edition, 32 bit, ver. 9.00.1399.06
OS: Win XP SP2, Czech version,
Microsoft Visual Studio 2005
Version 8.0.50727.42 (RTM.050727-4200)
Microsoft .NET Framework
Version 2.0.50727
Installed Edition: Professional
This seems to work fine for me. However, I don't happen to have the czech version of Windows XP handy to test this on.
Can you create and deploy other assemblies without seeing this error?
|||When I create a new database, I can deploy this assembly without problem. But, when I'm working with this db, I'm creating and modifying db objects (tables, users, etc.), because of developing an application, after some time (a few days) the database becomes a descripted state. Suddenly I cannot deploy the assembly. I can deploy it with SAFE permission set, but I cannot deploy it with UNSAFE.
On SQL server logs I found this message:
SqlDumpExceptionHandler: Process 57 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.
Here is SQL DUMP:
2006-01-10 09:57:36.85 Server Error: 17310, Severity: 20, State: 1.
2006-01-10 09:57:36.85 Server A user request from the session with SPID 54 generated a fatal exception. SQL Server is terminating this session. Contact Product Support Services with the dump produced in the log directory.
2006-01-10 09:58:41.79 spid57 Using 'dbghelp.dll' version '4.0.5'
2006-01-10 09:58:41.81 spid57 ***Stack Dump being sent to C:\...\LOG\SQLDump0025.txt
2006-01-10 09:58:41.81 spid57 SqlDumpExceptionHandler: Process 57 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.
2006-01-10 09:58:41.81 spid57 * *******************************************************************************
2006-01-10 09:58:41.81 spid57 *
2006-01-10 09:58:41.81 spid57 * BEGIN STACK DUMP:
2006-01-10 09:58:41.81 spid57 * 01/10/06 09:58:41 spid 57
2006-01-10 09:58:41.81 spid57 *
2006-01-10 09:58:41.81 spid57 *
2006-01-10 09:58:41.81 spid57 * Exception Address = 01C364AC Module(sqlservr+00C364AC)
2006-01-10 09:58:41.81 spid57 * Exception Code = c0000005 EXCEPTION_ACCESS_VIOLATION
2006-01-10 09:58:41.81 spid57 * Access Violation occurred reading address 000000B4
2006-01-10 09:58:41.81 spid57 * Input Buffer 510 bytes -
2006-01-10 09:58:41.81 spid57 * CREATE ASSEMBLY Test FROM 0x4D5A90000300000004000000FFFF00
2006-01-10 09:58:41.81 spid57 * 00B800000000000000400000000000000000000000000000000000000000000000000000
2006-01-10 09:58:41.82 spid57 * 000000000000000000800000000E1FBA0E00B409CD21B8014CCD21546869732070726F67
2006-01-10 09:58:41.82 spid57 * 72616D2063616E6E6F742062652072756E20696E20444F53206D6F64652E0D0D0A240000
2006-01-10 09:58:41.82 spid57 * 0000000000504500004C01030093A4BE430000000000000000E0000E210B010800002000
2006-01-10 09:58:41.82 spid57 * 000020000000000000CE3300000020000000400000000040000020000000100000040000
2006-01-10 09:58:41.82 spid57 * 00000000000400000000000000008000000010000046FC00000300000400001000001000
2006-01-10 09:58:41.82 spid57 * 00000010000010000000000000100000000000000000000000803300004B000000004000
2006-01-10 09:58:41.82 spid57 * 00B803000000000000000000000000000000000000006000000C000000F43200001C0000
2006-01-10 09:58:41.82 spid57 * 000000000000000000000000000000000000000000000000000000000000000000000000
2006-01-10 09:58:41.82 spid57 * 000000000000200000080000000000000000000000082000004800000000000000000000
2006-01-10 09:58:41.82 spid57 * 002E74657874000000D41300000020000000200000001000000000000000000000000000
2006-01-10 09:58:41.82 spid57 * 00200000602E72737263000000B803000000400000001000000030000000000000000000
2006-01-10 09:58:41.82 spid57 * 0000000000400000402E72656C6F6300000C000000006000000010000000400000000000
2006-01-10 09:58:41.82 spid57 * 000000000000000000400000420000000000000000000000000000000000000000000000
2006-01-10 09:58:41.82 spid57 * 000000000000000000000000000000000000000000000000000000000000000000000000
2006-01-10 09:58:41.84 spid57 * 000000000000000000000000000000000000000000000000000000000000000000000000
2006-01-10 09:58:41.84 spid57 * 000000000000000000000000000000000000000000000000000000000000000000000000
2006-01-10 09:58:41.84 spid57 * 000000000000000000000000000000000000000000000000000000000000000000000000
2006-01-10 09:58:41.84 spid57 * 000000000000000000000000000000000000000000000000000000000000000000000000
2006-01-10 09:58:41.84 spid57 * 000000000000000000000000000000000000000000000000000000000000000000000000
2006-01-10 09:58:41.84 spid57 * 000000000000000000000000000000000000000000000000000000000000000000000000
2006-01-10 09:58:41.84 spid57 * 000000000000000000000000000000000000000000000000000000000000000000000000
2006-01-10 09:58:41.84 spid57 * 000000000000000000000000000000000000000000000000000000000000000000000000
2006-01-10 09:58:41.84 spid57 * 000000000000000000000000000000000000000000000000000000000000000000000000
2006-01-10 09:58:41.84 spid57 * 000000000000000000000000000000000000000000000000000000000000000000000000
2006-01-10 09:58:41.84 spid57 * 000000000000000000000000000000000000000000000000000000000000000000000000
2006-01-10 09:58:41.84 spid57 * 000000000000000000000000000000000000000000000000000000000000000000000000
2006-01-10 09:58:41.84 spid57 * 0000000000000000000000000000
2006-01-10 09:58:41.84 spid57 *
2006-01-10 09:58:41.84 spid57 *
Can you email me the full log and the mini-dump (mdmp) file?
stevehem at microsoft dot com
Thanks
|||Thanks for reporting this and for sending me the dump.
This is a known issue that should be fixed in an upcoming service pack. It only applies to UNSAFE and EXTERNAL_ACCESS assemblies in databases that have been created by one Login then detached and reattached by another Login.
The workaround is to run:
exec sp_changedbowner '<username of the db attacher, ‘sa’, or any windows authenticated login>'
|||Greetings...I've same problem (CREATE ASSEMBLY fails with error "A severe error occurred on the current command.")...
And I'm trying to use Your solution, but I don't know what is "username of the db attacher"...
Can You help me?
Best regards...
|||
If using SQL authentication (you enter a username and password to connect to your server)
Code Snippet
EXEC sp_changedbown 'sa'should be enough. If your not using SQL authentication, (you connect using Integrated Security=SSPI or "Windows Security") try:
Code Snippet
EXEC sp_changedbown 'BUILTIN\Administrators'
No comments:
Post a Comment