C#2.0 Form to COM object?

B

Blaze1

I have a standalone app created in C# that is used to browse a database
of archived documents called DocDB.


We have some older legacy code written in Delphi that we wish to
enhance with the DocDB's functionality.


My idea was to give DocDB methods for controlling it from a seperate
process via COM (much like Word for example, but with only a few public
methods)


I have defined public methods in my forms based class, I have used an
SNK file, I successfully installed it into the GAC and run regasm. I
have also created a public interface for the few methods I need.


But no matter what I have done, the TLB that I create never exposes the
public methods when imported into my legacy app.


The code looks something like this (using C# 2.0):


namespace DocsDB
{


[Guid("3100EBCE-1E40-500b-A247­-C777D72BB2ED")]
public interface IDocsDBUI
{
void ViewDocsForLoan(int loan);
void IsVisible(bool visible);
void Quit();
}


[Guid("AA218A41-ED34-5f4e-95C1­-0F1DB0402AD9")]
[ProgId("DocsDB.App")]
[ClassInterface(ClassInterface­Type.AutoDual)]
public partial class frmMain : Form, IDocsDBUI
{


public frmMain()
{
InitializeComponent();
}


public void IsVisible(bool visible)
{
this.Visible = visible;
}


public void Quit()
{
this.Close();
}


public void ViewDocsForLoan(int loan)
{
// do something here
}


}



}


Can someone tell me what I might be doing wrong? A small working
example would be very much appreciated.
 
D

dan.c.roth

Hi

Are you using regasm to create the tlb?

like regasm.exe ActiveXScanner.dll /tlb:ActiveXScanner.tlb /codebase

Regards,

Daniel Roth
MCSD.NET
 
B

Blaze1

Yes.

I have now added the attribute [ComVisible(true)] to the
class/interface and now my methods are visible but trying to use the
COM object yields "Class not registered".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top