G
Guest
OK, Ive run my head into this wall for too long. I need help.
I am developing an applicaiton in C# to present a user with a GUI to specify
a configurable list of machines that he wants to listen to the output of.
Specify a filename to shove all of the data (into Excel), and start the whole
thing going. I get that done no problem. The problem comes with the Data.
The data is coming from a different application, and I am not 100% sure of
what it will be written in, so COM says I is the way to get this working. I
provide the other applicaiton with an interface to my class(es) for storing
data, and when this other app uses COM to call my exposed methods, I will
take care of the rest. Easy as pie. Alas, life isnt so good. I think I am
messing up somewhere in the registration of the TLB, or in the C# (this is my
first serious C# app)
My application is contained in one *.cs file, and it handles most of the GUI
stuff, and internal data storage. In another file I have defined the classes
to hold this very important data, some enums to help turn the integers into
strings, and an interface that contains the methods I want to expose to the
outside APP. All of the classes (there are 4) all inherit the same interface
(and implement all 4 methods, though 3 of them are blank returns).
Everything compiles nicely into a nice executable (*.exe).
Now, I run REGASM on the executable file generating a *.tlb file as well as
telling me it registers the classes in the registry (and I can see them in
the OLE/COM object viewer). Everything is looking great.
I need to test to see if the COM works though, and I do not know when/where
the real app is, so I decide to write a simple (I hope) C++ application which
will get the interface I expose, and send the data over to me. This simple
C++ app I view as the client, and the GUI in C# as the server. I hope I am
not innaccurate in those terms.
What I hope to see happening is starting up the C# app, and start it
listening for data, then starting up my dummy client app, and sending data to
the C# application via the exposed COM interface.
However, I cannot instantiate the object or the pointer. I am getting
errors that the file does not exist or windows cannot find the file. this is
from the C++ debugger. I look at the COM/OLE object viewer, and I notice on
right-click there is an instantiate object option, which returns the same
error.
I have no idea what I am doing right, and what I am doing wrong.
Can someone point me to a simple article on how to porperly export 4 C#
classes sharing an interface to COM (the most recent book tells me all I need
to do is regasm to do this). And then how to consume those objects in C++.
here is an example of the class in C#:
public interface IFoo
{
Populate1(int, int, int);
Populate2(int);
Populate3(int, int, string);
Populate4(int, string);
}
public class MyClass1 : IFoo
{
//Properties, etc
Populate1();
Populate2();
Populate3();
Populate4();
}
Same as above for the other 3 classes.
Any ideas? I am currently poring over _.NET and COM the Complete
Interoperability Guide_ trying to find something... but failing to see it.
Thanks
Andrew S. Giles
I am developing an applicaiton in C# to present a user with a GUI to specify
a configurable list of machines that he wants to listen to the output of.
Specify a filename to shove all of the data (into Excel), and start the whole
thing going. I get that done no problem. The problem comes with the Data.
The data is coming from a different application, and I am not 100% sure of
what it will be written in, so COM says I is the way to get this working. I
provide the other applicaiton with an interface to my class(es) for storing
data, and when this other app uses COM to call my exposed methods, I will
take care of the rest. Easy as pie. Alas, life isnt so good. I think I am
messing up somewhere in the registration of the TLB, or in the C# (this is my
first serious C# app)
My application is contained in one *.cs file, and it handles most of the GUI
stuff, and internal data storage. In another file I have defined the classes
to hold this very important data, some enums to help turn the integers into
strings, and an interface that contains the methods I want to expose to the
outside APP. All of the classes (there are 4) all inherit the same interface
(and implement all 4 methods, though 3 of them are blank returns).
Everything compiles nicely into a nice executable (*.exe).
Now, I run REGASM on the executable file generating a *.tlb file as well as
telling me it registers the classes in the registry (and I can see them in
the OLE/COM object viewer). Everything is looking great.
I need to test to see if the COM works though, and I do not know when/where
the real app is, so I decide to write a simple (I hope) C++ application which
will get the interface I expose, and send the data over to me. This simple
C++ app I view as the client, and the GUI in C# as the server. I hope I am
not innaccurate in those terms.
What I hope to see happening is starting up the C# app, and start it
listening for data, then starting up my dummy client app, and sending data to
the C# application via the exposed COM interface.
However, I cannot instantiate the object or the pointer. I am getting
errors that the file does not exist or windows cannot find the file. this is
from the C++ debugger. I look at the COM/OLE object viewer, and I notice on
right-click there is an instantiate object option, which returns the same
error.
I have no idea what I am doing right, and what I am doing wrong.
Can someone point me to a simple article on how to porperly export 4 C#
classes sharing an interface to COM (the most recent book tells me all I need
to do is regasm to do this). And then how to consume those objects in C++.
here is an example of the class in C#:
public interface IFoo
{
Populate1(int, int, int);
Populate2(int);
Populate3(int, int, string);
Populate4(int, string);
}
public class MyClass1 : IFoo
{
//Properties, etc
Populate1();
Populate2();
Populate3();
Populate4();
}
Same as above for the other 3 classes.
Any ideas? I am currently poring over _.NET and COM the Complete
Interoperability Guide_ trying to find something... but failing to see it.
Thanks
Andrew S. Giles