SQL Server Performance

ADODB call throwing "Invalid URI: The URI is empty" error

Discussion in 'SQL Server 2005 General DBA Questions' started by beyonder422, May 18, 2009.

  1. beyonder422 New Member

    I created a simple object to send an ADODB recordset via MSMQ and successfully tested it in a console app but when importing and using in SQL server 2005 I get an error.
    Is there a better way to set an ADODB rs via MSMQ from SQL 05? I can create exe and call via shell but want to try the CLR. Is there a manager vs unmanaged question here?
    -- Send object (failing code only)
    [SqlProcedure]
    public static void Send(SqlString queue, SqlString point, SqlString bodynumber, out SqlString msg)
    {
    ADODB.Recordset rs = new ADODB.Recordset(); // when commenting out this line I do not get the error below....... - HELP!!!!!
    } // end Send
    -- sql code
    create assembly SqlMSMQtools authorization dbo from 'C: empSqlMSMQtools.dll' with permission_set = unsafe
    go

    -- proc
    create PROCEDURE usp_MSMQ_SendAP46
    @queue nvarchar(500),
    @point nvarchar(100),
    @body_number nvarchar(10),
    @msg nvarchar(MAX) output
    AS EXTERNAL NAME SqlMSMQtools.[SqlMSMQtools.Basic].Send
    GO
    -- execute
    DECLARE @test nvarchar(1024)
    EXEC usp_MSMQ_SendAP46 @queue='FormatName:DIRECT=TCP:1.2.3.4\private$\XXX', @point='TestPoint',@body_number='123456', @msg = @test OUTPUT
    select @test
    -- error
    Msg 6522, Level 16, State 1, Procedure usp_MSMQ_SendAP46, Line 0
    A .NET Framework error occurred during execution of user defined routine or aggregate 'usp_MSMQ_SendAP46':
    System.UriFormatException: Invalid URI: The URI is empty.
    System.UriFormatException:
    at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
    at System.ComponentModel.Design.RuntimeLicenseContext.GetLocalPath(String fileName)
    at System.ComponentModel.Design.RuntimeLicenseContext.GetSavedLicenseKey(Type type, Assembly resourceAssembly)
    at System.ComponentModel.LicenseManager.LicenseInteropHelper.GetCurrentContextInfo(Int32& fDesignTime, IntPtr& bstrKey, RuntimeTypeHandle rth)
    at SqlMSMQtools.Basic.Send(SqlString queue, SqlString point, SqlString bodynumber, SqlString& msg)
  2. satya Moderator

    Have you enabled
    ALTER ASSEMBLY <you_assembly_name> WITH PERMISSION_SET=EXTERNAL_ACCESS

Share This Page