N
NvrBst
My problem is that it keeps returing nothing after calling the
methods. I "TlbImp.exe TEST.exe /out:TESTCS.dll" and then in C# Right
click > Add Reference > Browse and give it the TESTCS.dll.
It adds "TESTCS" and I can use intellasence to see all the methods. I
do
TESTCS.Flower myFlower = new TESTCS.Flower();
MessageBox.Show(myFlower.get_GetFlower(2));
The "myFlower.GetFlower(2)" COM is suppose to return the 2nd flower
(stored in registry), which is a string. When I do this it says to
call accessor method directly "myFlower.get_GetFlower(2);" and this
just returns null.
I can use the COM EXE from my ASP/JScript pages using "object myFlower
= Server.CreateObject("TEST.myFlower);" and "myFlower.GetFlower(2);".
Just doesn't want to work in a Windows Form C# App.
Any suggestions? I've tried late binding, it seems more complicated
and I don't need late binding but it doesn't work either. Late
Binding code below:
Type objClassType;
objClassType = Type.GetTypeFromProgID("TEST.myFlower");
object objApp_Late = Activator.CreateInstance(objClassType);
objApp_Late.GetType().InvokeMember("GetFlower",
BindingFlags.InvokeMethod, null, objApp_Late, new object[] {55555});
It crashes at runtime with a "TargetInvocationException: Exception has
been thrown by the target of an Invocation." on the last line.
Thanks NB
methods. I "TlbImp.exe TEST.exe /out:TESTCS.dll" and then in C# Right
click > Add Reference > Browse and give it the TESTCS.dll.
It adds "TESTCS" and I can use intellasence to see all the methods. I
do
TESTCS.Flower myFlower = new TESTCS.Flower();
MessageBox.Show(myFlower.get_GetFlower(2));
The "myFlower.GetFlower(2)" COM is suppose to return the 2nd flower
(stored in registry), which is a string. When I do this it says to
call accessor method directly "myFlower.get_GetFlower(2);" and this
just returns null.
I can use the COM EXE from my ASP/JScript pages using "object myFlower
= Server.CreateObject("TEST.myFlower);" and "myFlower.GetFlower(2);".
Just doesn't want to work in a Windows Form C# App.
Any suggestions? I've tried late binding, it seems more complicated
and I don't need late binding but it doesn't work either. Late
Binding code below:
Type objClassType;
objClassType = Type.GetTypeFromProgID("TEST.myFlower");
object objApp_Late = Activator.CreateInstance(objClassType);
objApp_Late.GetType().InvokeMember("GetFlower",
BindingFlags.InvokeMethod, null, objApp_Late, new object[] {55555});
It crashes at runtime with a "TargetInvocationException: Exception has
been thrown by the target of an Invocation." on the last line.
Thanks NB