COM Wrappeer

J

JSheble

I have a C# .NET Assembly that I need to expose as a COM Object, and have
had a partial success. First I created my C# class, and in the project
properties enabled the "Register for COM Interop" property. I created a
class, and used the ComVisible(true) attribute. SO far, so good...

I use a script editor that exposes COM objects, and I can see my newly
created object, and can create an instance of it ok. Now I wish to start
adding properties and methods, and I include the ComVisible(true) attribute
on them (although I'm not sure this is necessary). However, when I go inot
my script editor's object browser or even VB6's object browser, all I can
see is my main class, not the public properties or methods I've also
defined.

Any ideas what else I might be missing? BTW, I can still call those
properties and/or methods, I just can see them in OleView, or any other COM
Object browser...

TIA!!

Here's the class code... not much to it yet, just trying to get the
visiblity and structure down before I start adding all the serious code:

using System;
using System.Runtime.InteropServices;

namespace ManualShipper
{
[ComVisible(true)]
[Guid("F7401534-48A3-40e0-A4CC-09DC56EBC3CA")]
public class OrderLookUp
{
#region Internal Properties
#endregion

#region Private Vars
private string pTranslateXML = "";
#endregion

#region Private Methods
#endregion

#region Protected Properties
#endregion

#region Public Properties
[ComVisible(true)]
public string TranslateXML
{
get { return this.pTranslateXML; }
set { this.pTranslateXML = value; }
}
#endregion

#region Public Methods
[ComVisible(true)]
public void GetOrder(string sOrder)
{
}
#endregion

#region Constructors
public OrderLookUp()
{
}
#endregion
}
}
 
G

Gopi

Add the following attributes instead of [comvisible] attribute just above
your class declaration it should work fine
[GuidAttribute("EC632445-DFA9-4caa-BA36-8D238B96F945")]
[ClassInterface(ClassInterfaceType.AutoDual)]
Thanks
Gopalkrishna K.S
 
J

JSheble

Thanx... that did it...

Gopi said:
Add the following attributes instead of [comvisible] attribute just above
your class declaration it should work fine
[GuidAttribute("EC632445-DFA9-4caa-BA36-8D238B96F945")]
[ClassInterface(ClassInterfaceType.AutoDual)]
Thanks
Gopalkrishna K.S



JSheble said:
I have a C# .NET Assembly that I need to expose as a COM Object, and have
had a partial success. First I created my C# class, and in the project
properties enabled the "Register for COM Interop" property. I created a
class, and used the ComVisible(true) attribute. SO far, so good...

I use a script editor that exposes COM objects, and I can see my newly
created object, and can create an instance of it ok. Now I wish to start
adding properties and methods, and I include the ComVisible(true) attribute
on them (although I'm not sure this is necessary). However, when I go inot
my script editor's object browser or even VB6's object browser, all I can
see is my main class, not the public properties or methods I've also
defined.

Any ideas what else I might be missing? BTW, I can still call those
properties and/or methods, I just can see them in OleView, or any other COM
Object browser...

TIA!!

Here's the class code... not much to it yet, just trying to get the
visiblity and structure down before I start adding all the serious code:

using System;
using System.Runtime.InteropServices;

namespace ManualShipper
{
[ComVisible(true)]
[Guid("F7401534-48A3-40e0-A4CC-09DC56EBC3CA")]
public class OrderLookUp
{
#region Internal Properties
#endregion

#region Private Vars
private string pTranslateXML = "";
#endregion

#region Private Methods
#endregion

#region Protected Properties
#endregion

#region Public Properties
[ComVisible(true)]
public string TranslateXML
{
get { return this.pTranslateXML; }
set { this.pTranslateXML = value; }
}
#endregion

#region Public Methods
[ComVisible(true)]
public void GetOrder(string sOrder)
{
}
#endregion

#region Constructors
public OrderLookUp()
{
}
#endregion
}
}
 

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