Hi,
using .Net DLL in PB17 is a little bit tricky, you have to take care of some things.
First your .Net DLL:
- the DLL must be COM visible (see .Net project settings)
- the created class / object must be COM visible. Place this code over every class/object you want to call / create via OleObject
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDual)]
[ProgId("MYCLASS")]
- you must register the DLL. You are right, use REGASM, but check if the class / object you define with [ProgId("MYCLASS")] is correct placed in registry
EDIT:
- the class / object you call / create via OleObject must be PUBLIC, all parents must be PUBLIC too
- the class / object can not be static or abstract, best practices is to hold your class / object and all called functions simple as possible (means argument types, return value and any types of access modifier)
As Second, your PB-Object. I think a sample is the best help, so here is a snippet from an old project (work fine in PB17):
LONG ll_erg = 0
STRING ls_msg = ""
OleObject myOLe
myOLe = CREATE OleObject
TRY
CHOOSE CASE myOLe.ConnecTtoNewObject("MYCLASS")
CASE -1
ll_erg = in_e.icl_err_obj_invalid_call
ls_msg = in_e.sof_get_enum_txt(ll_erg) + " MSG: Invalid Call: the argument is the Object property of a control"
CASE -2
ll_erg = in_e.icl_err_obj_invalid
ls_msg = in_e.sof_get_enum_txt(ll_erg) + " MSG: Class name not found"
CASE -3
ll_erg = in_e.icl_err_obj_can_not_create
ls_msg = in_e.sof_get_enum_txt(ll_erg) + " MSG: Object could not be created"
CASE -4
ll_erg = in_e.icl_err_obj_can_not_con
ls_msg = in_e.sof_get_enum_txt(ll_erg) + " MSG: Could not connect to object"
CASE -9
ll_erg = in_e.icl_err_ext
ls_msg = in_e.sof_get_enum_txt(ll_erg) + " MSG: Other error"
CASE -15
ll_erg = in_e.icl_err_obj_not_load
ls_msg = in_e.sof_get_enum_txt(ll_erg) + " MSG: COM+ is not loaded on this computer"
CASE -16
ll_erg = in_e.icl_err_obj_invalid_call
ls_msg = in_e.sof_get_enum_txt(ll_erg) + " MSG: Invalid Call: this function not applicable"
CASE ELSE
ll_erg = in_e.icl_err_default
END CHOOSE
CATCH (Exception ex)
// handle Exception
CATCH (RUNTIMEERROR err)
// handle RunTimeError
END TRY
I hope it helps.
Greetings Eric
We had installed PB2017 64bit version. So when we run PB it runs in 64-bit.
The dll that we are trying to use was built in 32-bit as that of the other dll the application use.
Browsed to the PB2017 installed path and changed to compatibility mode. Now PB is able to identify the dll and our issue is resolved.