Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 .NET Inside SQL Server (2005)
 SQL 2005 CLR and MSVCRT.LIB

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2007-03-07 : 08:40:35
Yang writes "I have created a shared DLL which calls pow function from lib MSVCRT.LIB.

I need the DLL be executed in SQL 2005 server as a stored procedure

after following steps in SQL 2005 management studio

CREATE ASYMMETRIC KEY SQLCLRCppKey FROM EXECUTABLE FILE =
'C:\tmp\DllCppm.dll'

CREATE LOGIN SQLCLRCppLogin FROM ASYMMETRIC KEY SQLCLRCppKey

GRANT UNSAFE ASSEMBLY TO SQLCLRCppLogin

I tried to

CREATE ASSEMBLY DllCppm
FROM 'C:\tmp\DllCppm.dll'
WITH PERMISSION_SET=UNSAFE

An error message was displayed:

Msg 6218, Level 16, State 3, Line 1
CREATE ASSEMBLY for assembly 'DllCppm' failed because assembly 'DllCppm' failed verification. Check if the referenced assemblies are up-to-date and trusted (for external_access or unsafe) to execute in the database. CLR Verifier error messages if any will follow this message

How to solve the issue?


Following is the src code

// This is the main project file for VC++ application project
// generated using an Application Wizard.

#include "stdafx.h"
#include <math.h>

#using <mscorlib.dll>

using namespace System;
using namespace Microsoft::SqlServer::Server;

namespace Dll
{
/// <summary>
/// Summary description for Cppm.
/// </summary>
public class Cppm
{

public:

[SqlProcedure(Name="sp_MyCpp")]
static double testCpp()
{
double ans = pow(5.0, 2.3);
return ans;
};
};
}"
   

- Advertisement -