connecting to siebel

  • Thread starter Thread starter Pedro Duque
  • Start date Start date
P

Pedro Duque

I need to create a siebel object of a class defined in a
COM just as Interface.
In a VB sample they use the CreateObject
("SiebelDataServer.ApplicationObject") to create a
SiebelDataServer.SiebelApplication object, since the
SiebelApplication class is just an Interface thus not
allowing the use of "New
SiebelDataServer.SiebelApplication".
Since there is no equivalence to the VB CreateObject in
C#, how can i do this? Help anyone?
 
Pedro,

The type library for the interface should have a class definition.
Because of this, when the type library was imported, a class with a name of
SiebelApplicationClass should have been created. You should be able to do
this:

// Create the object.
SiebelDataServer.ApplicationObject pobjObject = new
SiebelDataServer.ApplicationObjectClass();

Basically, the word "Class" is appended to the interface definition to
indicate that you can instantiate that.

If it is not there in the type library, then you can do the following:

// Get the type from the program id.
Type pobjType =
Type.GetTypeFromProgID("SiebelDataServer.ApplicationObject");

// Create an instance of the type.
SiebelDataServer.ApplicationObject pobjObject =
(SiebelDataServer.ApplicationObject) Activator.CreateInstance(pobjType);

Basically, you are getting a type that represents a COM type and then
creating an instance of that type through the call to the static
CreateInstance method on the Activator class.

Hope this helps.
 
Back
Top