PC Review


Reply
Thread Tools Rate Thread

C#2.0 Form to COM object?

 
 
Blaze1
Guest
Posts: n/a
 
      9th May 2005
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.

 
Reply With Quote
 
 
 
 
dan.c.roth@gmail.com
Guest
Posts: n/a
 
      10th May 2005
Hi

Are you using regasm to create the tlb?

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

Regards,

Daniel Roth
MCSD.NET

Blaze1 wrote:
> 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.


 
Reply With Quote
 
Blaze1
Guest
Posts: n/a
 
      10th May 2005
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".

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
object does not contain automation object form- error vandy Microsoft Access Macros 5 4th Jun 2008 09:20 AM
how to casting a object inherit form Form to another object in c# 2.0 harvie wang Microsoft C# .NET 2 29th Apr 2006 11:18 PM
IDE bug? deleted form object persists on object list =?Utf-8?B?Q2hyaXNfaA==?= Microsoft Access Form Coding 5 28th Jul 2005 04:45 PM
Calling another form's object event - error msg... object required =?Utf-8?B?bHA=?= Microsoft Access Forms 2 22nd Dec 2004 11:38 PM
updating form object using class object =?Utf-8?B?Q2hyaXM=?= Microsoft Dot NET 0 10th Dec 2004 03:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:47 PM.