Windows XP: registering COM Object for use in SQL Server 2000

Caporegime
Joined
18 Oct 2002
Posts
32,641
I recently made a COM object that wraps around a .NET library which I want to use from SQL Server 2000 (I made a post about this previously).

I successfully developed and tested the code on my own test setup but it is failing to work on a clients system and I believe the errors are pointing towards failing to find the library file.


One of the complexities that I really don't understand in windows is the whole malarkey about registering these COM objects in the windows registry and adding the object to the Global Assembly Cache. I found out that you first have to call the 'regasm.exe' tool to register the assembly, and then the 'gacutil' tool to install the library somewhere. I tested these tools and they worked on my setup, I then made a batch file which would automatically run the tools on the clients computer.

This seemed to work without giving any errors. But I am wondering if this is some kind of user/permissions/rights problem. The SQL server is probably running as a Sys Admin while when my library was installed by the client they had some standard user without SA rights.


However, I am very lost, and this way out of my understanding (I develop algorithms by profession and don't mess with Windows ugliness).

It is kind of critical that this is resolved within the next 2 hours otherwise the project gets delay another few weeks.:(
 
Seems it wasn't a privileges thing. I then thought it was a problem running gacutil.exe but that didn't make a difference.

Here is the offending SQL code:

Code:
create procedure DPServerConfig (
    @hostStr VARCHAR(100),
	@portNum Int )
AS
BEGIN
    DECLARE @comHandle INT
    DECLARE @retVal INT
    DECLARE @errorSource VARCHAR(100)
    DECLARE @errorDescription VARCHAR(100)
    DECLARE @retNum Int
   
    -- Create a handle to the COM object 
    EXEC @retVal = sp_OACreate 'GDSignalServer.Trigger', @comHandle OUTPUT
	-- Capture any error
    IF (@retVal <> 0)
    BEGIN
	   EXEC sp_OAGetErrorInfo @comHandle, @errorSource OUTPUT, @errorDescription OUTPUT
	   SELECT @errorSource, @errorDescription
    END
   
    -- Call the 'configure' method of the COM library, specify the host name and port number 
    EXEC @retVal = sp_OAMethod @comHandle, 'configure', @retNum OUTPUT, @hostname=@hostStr, @port =@portNum
    IF (@retVal <> 0)
    BEGIN
	   -- Trap errors if any
       EXEC sp_OAGetErrorInfo @comHandle, @errorSource OUTPUT, @errorDescription OUTPUT
       SELECT [Error Source] = @errorSource, [Description] = @errorDescription
       RETURN
    END
END
go	

exec DPServerConfig '127.0.0.1', 2012
go


This is the error
Code:
Error Source: ODSOLE Extended Procedure
Error Description: sp_OAMethod usage:  ObjPointer int IN, MethodName varchar IN [, @returnval <any> OUT [, additional IN, OUT, or BOTH params]]
 
I had the following as a bath file to register the library once installed:
Code:
@ECHO off
ECHO Registering the GDSignalServer Trigger
%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\regasm.exe "C:\Program Files\GDSignalTrigger2000\GDSignalServerTrigger.dll" /tlb:"C:\Program Files\GDSignalTrigger2000\GDSignalServerTrigger.tlb" 

ECHO    
ECHO Adding Assembly to the cache

gacutil /i "C:\Program Files\GDSignalTrigger2000\GDSignalServerTrigger.dll"

PAUSE


The regasm seemed to run fine.
 
Back
Top Bottom