Hi,
I've just started with PB and have been tasked with creating a com dll to be used in a c# project. To begin with I've used the following example to create a com dll:
This successfully compiles, the type library is embedded and the dll is registered.
If I create a simple PB client to access this class it works. However, from Visual Studio, the following c# code:
although it compiles (thanks to 9.01 of PB), when run it generates the following exception:
I'm at a complete loss, it appears not to like the argumentbeing passed to the method.
Cheers,
Niall
I've just started with PB and have been tasked with creating a com dll to be used in a c# project. To begin with I've used the following example to create a com dll:
Code:
#COMPILE DLL #COM TLIB ON #RESOURCE "MyClass.pbr" #DIM ALL #COM NAME "MyClass", 1.00 #COM DOC "Example Class" $MyClassGuid = GUID$("{00000099-0000-0000-0000-000000000008}") $MyIfaceGuid = GUID$("{00000099-0000-0000-0000-000000000009}") '------------------------------------------------------------------------------------------------------------------------------------------------------ CLASS MyClass $MyClassGuid AS COM INSTANCE Counter AS LONG INTERFACE MyInterface $MyIfaceGuid INHERIT DUAL ' inherit the base class METHOD BumpIt(Inc AS LONG) AS LONG LOCAL Temp AS LONG Temp& = Counter + Inc INCR Counter METHOD = Temp& END METHOD END INTERFACE END CLASS
If I create a simple PB client to access this class it works. However, from Visual Studio, the following c# code:
Code:
using System; using MyClass; namespace simplecom { public class Class1 { public static void Main(String[] Args) { MyClassClass Stuff = new MyClassClass(); int value, x, y; value = 77; x = Stuff.BUMPIT(ref value); y = Stuff.BUMPIT(ref value); Console.WriteLine("x: {0}, y: {1}", x, y); } } }
Code:
Unhandled Exception: System.InvalidCastException: Unable to cast COM object of type 'MyClass.MyClassClass' to interface type 'MyClass.MYINTERFACE'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00000099-0000-0000-0000-000000000009}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)). at MyClass.MyClassClass.BUMPIT(Int32& INC) at simplecom.Class1.Main(String[] Args) in z:\Visual Studio 2008\Projects\simplecom\simplecom\Class1.cs:line 16
Cheers,
Niall
Comment