473,513 Members | 3,317 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# COM Object Issues

Hi all,

At a high level here is what is going on -- I built a C# COM object. I need to call this com object from SQL Server using the sp_OACreate stored procedure in SQL Server. I build the COM object, register it using regasm, but when I try to call it in SQL Server I get the following error message - "0x80070002 Extended Procedure The system cannot find the file specified." I have tried registering the DLL with regsvr32 and that returns the message "fsi.dll was loaded, but the DllRegisterServer entry point was not found. DllRegisterServer may not be exported, or a corrupt version of fsi.dll may be in memory. Consider using PView to detect and remove it." Well I checked PView and there are no fsi.dll in memory. So, what my hopes are that someone has built a COM object in .NET, registered it, and was able to call it using sp_OACreate. Any help or ideas at this point would be greatly appreciated.

Step 1 (C# COM Source Code [compiled with COM Interoptibility set to true]
-----------------------------------------------------
using System;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;
namespace fsi
{
public class com : System.ComponentModel.Component
{
private System.ComponentModel.Container components = null;
public static void Main()
{

}

public static void Main(string[] args)
{

}

public com(System.ComponentModel.IContainer container)
{
///
/// Required for Windows.Forms Class Composition Designer support
///
container.Add(this);
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}
public com()
{
///
/// Required for Windows.Forms Class Composition Designer support
///
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

public string test()
{
return "Success";
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}
Step 2 (Register dll on server with regasm)
- Returns success

Step 3 (Call base stored procedure on server)
------------------------------------------------------
DECLARE @object int
DECLARE @hr int
DECLARE @src varchar(255), @desc varchar(255)
EXEC @hr = sp_OACreate 'fsi.com', @object OUT
IF @hr <> 0
BEGIN
EXEC sp_OAGetErrorInfo @object, @src OUT, @desc OUT
SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc
RETURN
END
Jul 21 '05 #1
4 8481
My apologies for the second post. When I did the first one I received a failure message that my message did not make it because an error occurred. However, it appears it still did...
Jul 21 '05 #2
Your C# COM object needs to be a class library - your code below looks like
an exe. Something like this in your class library is what it should look
like. Obviously the guids and progid need to match what the client is
expecting. Then run regasm on it. I've no idea how SQL gets to your COM
method, so what follows is a guess, but if it really is COM it will require
a Guid or a progid, and I expect it might be late binding, so the parameters
need to be automation-compatible (stick to string, int ! ).

[ComVisible(true), GuidAttribute(" get a unique guid here")]
[ProgId("Your.progid")]
public class someclass
{

public string somemethod ()
{
return "hello";
}
}
--
Phil Wilson [MVP Windows Installer]
----
"gman997" <gm*****@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com...
Hi all,

At a high level here is what is going on -- I built a C# COM object. I need to call this com object from SQL Server using the sp_OACreate stored
procedure in SQL Server. I build the COM object, register it using regasm,
but when I try to call it in SQL Server I get the following error message -
"0x80070002 Extended Procedure The system cannot find the file specified."
I have tried registering the DLL with regsvr32 and that returns the message
"fsi.dll was loaded, but the DllRegisterServer entry point was not found.
DllRegisterServer may not be exported, or a corrupt version of fsi.dll may
be in memory. Consider using PView to detect and remove it." Well I
checked PView and there are no fsi.dll in memory. So, what my hopes are
that someone has built a COM object in .NET, registered it, and was able to
call it using sp_OACreate. Any help or ideas at this point would be greatly
appreciated.
Step 1 (C# COM Source Code [compiled with COM Interoptibility set to true]
-----------------------------------------------------
using System;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;
namespace fsi
{
public class com : System.ComponentModel.Component
{
private System.ComponentModel.Container components = null;
public static void Main()
{

}

public static void Main(string[] args)
{

}

public com(System.ComponentModel.IContainer container)
{
///
/// Required for Windows.Forms Class Composition Designer support
///
container.Add(this);
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}
public com()
{
///
/// Required for Windows.Forms Class Composition Designer support
///
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

public string test()
{
return "Success";
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}
Step 2 (Register dll on server with regasm)
- Returns success

Step 3 (Call base stored procedure on server)
------------------------------------------------------
DECLARE @object int
DECLARE @hr int
DECLARE @src varchar(255), @desc varchar(255)
EXEC @hr = sp_OACreate 'fsi.com', @object OUT
IF @hr <> 0
BEGIN
EXEC sp_OAGetErrorInfo @object, @src OUT, @desc OUT
SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc
RETURN
END

Jul 21 '05 #3
The methods/properties of your class object that need to be exposed through COM need only be defined as 'public'.

Once your DLL is generated it will need to be installed in the GAC on the target computer for all other programs to use. See http://support.microsoft.com/default...b;en-us;815808.

"gman997" wrote:
Hi all,

At a high level here is what is going on -- I built a C# COM object. I need to call this com object from SQL Server using the sp_OACreate stored procedure in SQL Server. I build the COM object, register it using regasm, but when I try to call it in SQL Server I get the following error message - "0x80070002 Extended Procedure The system cannot find the file specified." I have tried registering the DLL with regsvr32 and that returns the message "fsi.dll was loaded, but the DllRegisterServer entry point was not found. DllRegisterServer may not be exported, or a corrupt version of fsi.dll may be in memory. Consider using PView to detect and remove it." Well I checked PView and there are no fsi.dll in memory. So, what my hopes are that someone has built a COM object in .NET, registered it, and was able to call it using sp_OACreate. Any help or ideas at this point would be greatly appreciated.

Step 1 (C# COM Source Code [compiled with COM Interoptibility set to true]
-----------------------------------------------------
using System;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;
namespace fsi
{
public class com : System.ComponentModel.Component
{
private System.ComponentModel.Container components = null;
public static void Main()
{

}

public static void Main(string[] args)
{

}

public com(System.ComponentModel.IContainer container)
{
///
/// Required for Windows.Forms Class Composition Designer support
///
container.Add(this);
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}
public com()
{
///
/// Required for Windows.Forms Class Composition Designer support
///
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

public string test()
{
return "Success";
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}
Step 2 (Register dll on server with regasm)
- Returns success

Step 3 (Call base stored procedure on server)
------------------------------------------------------
DECLARE @object int
DECLARE @hr int
DECLARE @src varchar(255), @desc varchar(255)
EXEC @hr = sp_OACreate 'fsi.com', @object OUT
IF @hr <> 0
BEGIN
EXEC sp_OAGetErrorInfo @object, @src OUT, @desc OUT
SELECT hr=convert(varbinary(4),@hr), Source=@src, Description=@desc
RETURN
END

Jul 21 '05 #4
Thanks Guys!! It works, I added the strong name followed by the directions in the knowledge base. I also added the attributes as suggested by Phil. I added the dll to GAC and then ran regasm. Hopped back into SQL Server and bingo it all works. I am listing the updated source code here for reference to others. This is really cool though calling a .NET method from SQL Server with COM.

using System;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;
namespace fsi
{
using interop = System.Runtime.InteropServices;
[
interop.ComVisible(true),
interop.Guid("78A7E9AD-B31B-3AF0-B931-2E1258CC1BD1")
]

public class com : System.ComponentModel.Component
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public static void Main()
{

}

public static void Main(string[] args)
{

}

public com(System.ComponentModel.IContainer container)
{
///
/// Required for Windows.Forms Class Composition Designer support
///
container.Add(this);
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}
public com()
{
///
/// Required for Windows.Forms Class Composition Designer support
///
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

public string test()
{
return "Success";
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
}
}

Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
5561
by: Rodd Snook | last post by:
I have an application which makes extensive use of the Scripting.Dictionary object. I'm not doing anything silly like putting them outside the page scope -- just creating quite a few of them and stuffing quite a lot of data (from and MS SQL database) into them. On Windows 2000 server, everything is fine. If the data structures get really...
2
1632
by: Unruled Boy | last post by:
1.The follow two ways to declare one object: any difference? especially its performance. a.Private m_objMyObject As MyObject=New MyObject() b.Private m_objMyObject As MyObject m_objMyObject=New MyObject 2.Any difference between a and b? a. For Each childItem In SomeItems Dim objData As DataObject=m_objOneSource.GetData(childItem.ID)
0
2020
by: Craig Rodrigues | last post by:
REQUEST FOR DISCUSSION (RFD) unmoderated group comp.object.corba.tao This is a formal Request For Discussion (RFD) to create comp.object.corba.tao as an unmoderated world-wide Usenet newsgroup dedicated to the discussion of The ACE ORB (TAO). This is not a Call for Votes (CFV); you cannot vote at this time. Procedural details appear...
6
2545
by: solex | last post by:
Hello, I am trying to use serialization to copy objects. The object in question "Institution" inherits from a parent object "Party" both are marked as <Serializable()>. Initially I can copy an empty Institution to another empty Institution, using the following routine: Private Sub CopyObject(ByRef FromObject As Object, ByRef ToObject As...
12
5507
by: Andrew Poulos | last post by:
With the following code I can't understand why this.num keeps incrementing each time I create a new instance of Foo. For each instance I'm expecting this.num to alert as 1 but keeps incrementing. Foo = function(type) { this.num = 0; this.type = type this.trigger(); } Foo.prototype.trigger = function() {
45
2958
by: bigdadro | last post by:
I've created a new class using prototype.js. After I make the ajax.request all references to this.myClassMethodorVariable are lost. Does the ajax method blow out the object persistance? I'm fairly new to OOP javascript so could be (and probably am) overlooking some detail. Below is the logic of what i'm trying to do. //Javascript code var...
13
1972
by: TS | last post by:
Say i have a class car with properties: Color, Make, Model, Year, DriverID And a Driver class with properties: DriverID, Name The driverID PRIVATE property is the id of the driver from say a driver table (t_driver). This has a PUBLIC property accessor called Driver My understanding of OO using the composition model is that when you want to...
8
3548
by: cj | last post by:
In 2003 I sometimes changed the startup object of a project to Sub Main which was found in Module1.vb. I upgraded one such project to 2005 and I notice in the properties page for the project that nothing is selected as the startup object. It appears to function but should I set it to Sub Main?
1
2323
by: =?Utf-8?B?U2NvdHQ=?= | last post by:
Hello, Using VS2008 in a C# web service application, a class has been created that inherits from the ConfigurationSelection. This class file has been placed in the App_Code folder. The web.config has been updated with the necessary section. Using System.Web.Configuration.WebConfiguration.GetSection(), the config information is returned...
9
1639
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I am just starting to write some code in C#. One time I accidently used "object" instead of "Object". The program didn't complain at all and worked fine. I am just wondering is there any difference between object and Object in C#? thanks --
0
7177
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7394
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7559
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7123
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5701
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5100
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4756
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3237
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
470
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.