Kr00l / VBCCR

VB Common Controls Replacement Library
MIT License
104 stars 46 forks source link

Referencing VBCCR13 or VBCCR15 from VB.net error #1

Closed melanysoft closed 6 years ago

melanysoft commented 6 years ago

Hi Krool, I'd like to thank you and express my respect to the project you have built and maintain. Your controls are great and stable so I implemented some of them my software product in Serbia. If there is something you need help with, I'd be glad to do that (if capable :)

As for the issue, it's about referencing the VBCCR library (or any of user-controls built using VBCCR components) from VB.net (tried versions 2013-2017).

VB.net interops with ActiveX controls making a wrapper automatically. It works for MSHFlex, my own VB6 built user controls, and some other controls I've tried. But when referencing VBCCR13.ocx (or VBCCR15.ocx) following warning errors occur preventing Vb.net to build the wrapper:

1.Error loading type library/dll (TYPE_E_CONTLOADLIBRARY) - 0x80029C4A
2.Could not determine the dependencies of the COM reference "VBCCR15". Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY))            
3.Could not determine the dependencies of the COM reference "VBRUN". Type mismatch. (Exception from HRESULT: 0x8002802A (TYPE_E_WRONGTYPEKIND))
4.The referenced component 'VBCCR15' could not be found.

Now, I must mention that the component is registered correctly and fully functional from within VB6.

Note

  1. The same happens when loading with OleView's "TypeLib Viewer"
  2. The VBCCR10 can be viewd with "TypeLib Viewer", still can't be referenced from .Net, but with only one error - the Could not determine the dependencies of the COM reference "VBRUN" (No.3).

The question is, do you have any idea, or some advice what should I do, or where to start looking in the source code to help resolve this issue, and make VBCCR referable from within VB.net ?

Thanks andd best regards,

Milan

Kr00l commented 6 years ago

Thanks for your report. VBRUN is used in some enums and object types and accessible public interface wise. The error in type lib. I don't know. Have you installed OLEGuids.tlb ? Normally it's not needed as it gets compiled into and there is no public declaration from it. But who knows, maybe .net has problems without it. I just can confirm that office vba will run it. For .net it's not tested but would be great if it works there too.

Please try VBCCR15 only. The older had some critical flaws for some vtable handling.

melanysoft commented 6 years ago

Thanks Krool, I'll investigate more and try to find a fix. I'm trying with VBCCR15,and yes, I did install OLEGuids.tlb. Ill post you the fix if/when I find it :)

melanysoft commented 6 years ago

The reason for unsuccessful creation of AxInterop wrapper is a "faulty" definition of property Value in the class Hotkey. The problem is caused by using ByRef definition of parameter Modifiers.

Definitions that don't work:

Public Property Get Value(Optional ByRef Modifiers As VBRUN.ShiftConstants) As VBRUN.KeyCodeConstants

and

Public Property Let Value(Optional ByRef Modifiers As VBRUN.ShiftConstants, ByVal NewValue As VBRUN.KeyCodeConstants)

Working definitions:

Public Property Get Value(Optional ByVal Modifiers As VBRUN.ShiftConstants) As VBRUN.KeyCodeConstants

and

Public Property Let Value(Optional ByVal Modifiers As VBRUN.ShiftConstants, ByVal NewValue As VBRUN.KeyCodeConstants)

After compiling, VB.Net (and C#) can import VBCCR15 controls and place them directly on .Net forms. But, while testing in VS 2013, so far I've managed to put only the LabelW control without a crash. I've tried: TextBoxW, CommandButtonW and OptionButtonW and all of them resulted in crashing the IDE right after they're shown on the form.

Preceding the crash, all controls get fully drawn on the form with their default properties, although I must note that the size of them is "square" and not following the mouse pattern drawn while placing.

They don't crash if I first place them on a VB6 UserControl and then alltogether wrap in .Net. It looks like there is some problem while reading the container properties of .Net Form.

Please check if suggested fix fits with the rest of the project.

BR, Milan

Kr00l commented 6 years ago

Thanks so far.

Public Property Get Value(Optional ByVal Modifiers As VBRUN.ShiftConstants) As VBRUN.KeyCodeConstants

It is intended that Modifiers is ByRef and not ByVal. Can you please try if 'ByRef Modifiers As Integer' will also fix the issue?

Suggested new definitions to be tested:

Public Property Get Value(Optional ByRef Modifiers As Integer) As VBRUN.KeyCodeConstants

and

Public Property Let Value(Optional ByRef Modifiers As Integer, ByVal NewValue As VBRUN.KeyCodeConstants)

melanysoft commented 6 years ago

Hi Krool, sorry for not being able to test the suggested solution before - a busy month I guess. Anyway, it works when defined as you suggested.

Is this solution going to be implemented in VBCCR15, or do you suggest me to keep this on a private fork ?

From the InteliSense point it's always useful to have an enumerator, so maybe it would be OK to redefine (rewrite) the VBRUN.ShiftConstants to VBCCR version, using same names and values as in the original.

Thanks, BR

sohailfayez commented 7 months ago

SSDSD