RE: Exposing DotNet assemblies to COM

  • From: "Jamal Mazrui" <Jamal.Mazrui@xxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Fri, 1 Feb 2008 13:37:21 -0500

Jay,
I think a static singleton related method could be called internally by
your code, perhaps by the Client constructor method.  Let me know if
this template clarifies matters.

In the source code of the SSIP assembly, 
the namespace is SSIP4Windows
And the class is Client 

Thus, regasm.exe creates the progID SSIP4Windows.Client in the Windows
registry.  I don't know if this is necessary, but I suggest using a
ProgID with only one period symbol at first.

Test C# code might be

using SSIP4Windows;

class Test {
static void Main() {
object oSSIP = new Client();
string sText = "Hello world";
oSSIP.SayImportant("Hello world");
} // Main method
} // Test class
 
 
 Jamal



-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Macarty, Jay
{PBSG}
Sent: Friday, February 01, 2008 1:14 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: RE: Exposing DotNet assemblies to COM 

Jamal,
Thanks for the feedback. The GetInstance method is there as a way to
create a singleton of the client. However, it does also support a
0-argument regular constructor as required by COM. I've tried using the
namespace.classname construct and a progid directive both.

namespace.classname version
$voice = ObjCreate("SSIP.Client.SSIPClient")  

using progid defined in the assembly just before the class $voice =
ObjCreate("SSIP4Windows.Client") 

If I run regasm with the /regfile option, I can see that it says it is
creating the progid by looking at the .reg file. As you might guess, the
code sample above is autoIt 3. Haven't tried it in another language yet.
I have the SSIPClient.dll and the SSIPClient.tlb files both in the same
directory as the au3 script but that doesn't seem to help.

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Jamal Mazrui
Sent: Friday, February 01, 2008 11:31 AM
To: programmingblind@xxxxxxxxxxxxx
Subject: RE: Exposing DotNet assemblies to COM 

Is GetInstance a static method?  The regasm utility only exposes public
classes and instance members via COM.  Try putting the GetInstance code
inside a class constructor method.   When the COM client uses
CreateObject (or equivalent), the ProgID passed should (by default) be a
"NamespaceName.ClassName" string.  The return value will be an object
instance of the class.

Hope this helps,
Jamal
--Original Message--
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Macarty, Jay
{PBSG}
Sent: Friday, February 01, 2008 11:12 AM
To: programmingblind@xxxxxxxxxxxxx
Subject: Exposing DotNet assemblies to COM 

All,
The good news is that I have a DotNet assembly to access the SSIP voice
server now; so, you can include it and use the methods like SayImportant
or SayText (there is a Say method for each of the 5 SSIP voice priority
levels). Also, you can use the properties like API or Voice to control
the output. A typical use of the SSIPClient at the beginning of a
program might look something like this:

using SSIPClient;
....
  public SSIPDemo()
  {
    SSIPClient voice = SSIPClient.GetInstance(); // default to localhost
port 3891 
    voice.API = "AUTO"; // look for active screen reader or SAPI 
    voice.SayImportant("Demo program now running");
  }

Since the "AUTO" setting is actually the default for the API property,
that line wasn't truly necessary. It just showed how to set the value.
Other values for this property include JAWS, WINEYES, SA, and SAPI if
you know which interface you wish to use.

My problem is this. I am trying to expose the methods and properties of
the SSIPClient to COM so the client can be used by any language
supporting COM objects. This is supposed to be a relatively simple task
I have included the [ComVisible(true)] directive and the other COM
directives suggested in the book I have. It compiles and I can run the
regasm utility and it says that the library was registered successfully.
However, I get an error in my script when I try to create the COM
object. 

Does anyone have some pointers on exposing DotNet classes to COM or
where I can find some good documentation on this topic?
      


------------------------------------------------------------
Jay Macarty - Masterfiles Technical Lead - PBSG
Phone: 972-963-1387
 Cell: 214-549-3421
__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind
__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

Other related posts: