Find first Edge C# ERROR

Hello,
My program was running OK after adding the “Common Vision Image Control” and suddenly these 2 error pop up on my Form1.cs[Design]

1.-Could not find type ‘AxCVIMAGELib.AxCvEdge’. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built using settings for your current platform or Any CPU.

2.-Could not find type ‘AxCVEDGELib.AxCvEdge’. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built using settings for your current platform or Any CPU.

I know it is problem with libraries, but I really don’t know how to solve it. Now I can not even add the tool Common Vision Image Control to my toolbox because of this:
"The control in not enabled in the active designer. Make sure the controls to add are compatible with the current designer and NET Framework version"

My current project is x64, I know that control is 2010 x32 but it was running OK until now, and when I open the Tutorial solution from Edge folder, it is running in x64 and working perfectly.

As you can see, I am not an expert C# programmer but I was doing well until now. I know you suggested do not using the 2010 Edge and go to Foundations but we really do not know how to convert that 2010 edge tool. The “old” version tool is quite simple and understandable. Is there any possibilities of using it on my x64 C# vision program?
How can I solve those libraries recurrent errors?

Thank you very much!!

George

The Controls appeared again in my Toolbox but when I try to drag them into my Form this happends (attach photo)

Please I need help!
Thank you

Hi @George,

ActiveX controls in .Net projects can sometimes be a bit bumpy… When you add an ActiveX control to a C# or VB.Net project, a reference to the actual COM object is added to your project. To make the actual control usable, Visual Studio (or rather: tlbimp and aximp) will build a wrapper DLL for you based on the content of the control’s type library. These auto-generated wrappers are named like AxInterop.CVDISPLAYLib.dll and Interop.CVDISPLAYLib.dll (with the actual names also derived from the content of the control’s type library). These DLLs expose a managed interface that you application can call on to use the control, and to be on the safe side, these wrappers are recreated very frequently by Visual Studio.

Now there are, unfortunately, a few things that can go wrong that might cause the symptoms that you are seeing - and I’ll try to describe them for you:

1. Unmatched Target Platform and :cvb: installation

:cvb: can only ever be installe for either x64 or win32 - never both of them at the same time. That means that all the ActiveX controls that are part of :cvb: are either available as 64 bit binaries or as 32 bit binaries!

To draw the full picture: The x64 installers of :cvb: will actually also install a set of 32 bit ActiveX controls but these are not actually usable outside the Visual Studio Designer

Should a managed application try to access the :cvb: ActiveX controls, it must run as a process targeting the appropriate architecture:

  • x64 or IL (=“AnyCPU”) without the prefer 32 bit flag set for 64 bit
  • x86 or IL with the prefer 32 bit flag set for 32 bit

2. Rotten Auto-generated Wrappers

We have seen cases where switching the application between different target platforms (x64, x86, IL) led to wrappers that were no longer usable. This is fairly simple to fix usually:

  1. In Visual Studio make sure you have defined the configuration you want to build properly with respect to the target platform. When building versus a Framework > 4.0 please also make sure that the Prefer 32 bit flag has been set the way you need it if you are building towards IL. Ideally, to prevent future mayhem you should remove configurations that you won’t actually need.
  2. Close visual Studio.
  3. Open the project folder in Windows Explorer and delete the bin and the obj folder (of course you should make sure that especially the bin folder no longer contains things you’d actually need).

This will force Visual Studio to rebuild the wrappers and if everything goes according to plan this should get you up and running again.

3. Messed up :cvb: Installation

Should in theory not happen, but who knows…
For example if binaries from different installations have been mingled it may happen that a DLL does not match the expectation of the ActiveX controls and/or its dependencies any more. Such a case isn’t usually occurring a clean installation and can be easily diagnosed by checking whether the OCX-based tutorials that come with CVB are still working (for example %CVB%\Tutorial\Edge\CSharp or %CVB%\Tutorial\Edge\VC\VCEdgeOCX for the Edge control). If they are, then your installation is obviously not the culprit. If they don’t work either, then a clean install of :cvb: is recommendable.

Recommendation

From what you initially wrote and what you already checked that, I would think that #3 is not the problem. From the error messages you quote it is most likely #1, maybe #2.

2 Likes

Hello!
Thank you very much for your reply. It helps!
One last doubt: I am taken those AX tools from your Tutorials. Where are located the x64 AX Tools?
Thank you very much!

Hi @George,

I am honestly not entirely certain what you refer to with the term “x64 AX Tools”, but I assume you are asking where the 64 bit build of our ActiveX controls can be found? If that is the case, my answer is:

  • If you have installed a 32 bit build of Common Vision Blox
    In this case the 32 bit build of the ActiveX control can be found in the installation directory (%CVB%). The files with the extension *.ocx are the ones that implement the ActiveX controls. No 64 bit builds of our ActiveX controls is installed in this scenario!
  • If you have installed a 64 bit build of Common Vision Blox
    In this case the 64 bit build of our ActiveX controls can (again) be found in the installation directory (%CVB%). Also, the 32 bit builds intended for the Visual Studio designer have been installed into the folder %CVB%\Wow6432. Please keep in mind that these are not suitable for productive use.

Under no circumstances will you have the 64 bit builds of the ActiveX controls and the 32 bit builds of the ActiveX controls intended for productive use on the same system.

Hello, thank you for the answer.
We have installed CVB x64
I am trying to explain it better.
These are the tools I am talking about:
Common Vision Display control (named in properties as axCVdisplay)
Common Vision Edge control (named in properties as axCVedge)
Common Vision Image control (named in properties as axCVimage)
Photo:
2

We really want to use those Display control, Edge control and Image control because they are simple and they were developed by CVB to make our life easier :wink:
Someone in Stemmer told us that we need to use Foundations instead but there are no examples, or code ready to use or tools like those ones. By the way Display control, Edge control and Image control are available in your tutorials in the folder EDGE, the same folder Stemmer invited to use when we called to ask for help. So we did.
Have been hundreds of hours to make our current program using Display control, Edge control and Image control, currently they are working but I am afraid they will crash.
I know you are here to help, and you are doing it very well but I think it is not fair for the customers just saying “use Foundations” because in the past CVB had all the tools we needed ready to use, like Display, Edge and Image controls. If we can not use them, we need that your company give us the same tools but x64 working, please.
I hope you see the problem now!
I really appreciate your help, believe me, actually you are the only help we have.
Thank you very much


I am using these libraries for those tools:


This is my form[Design]


and this is my .exe

I am using these Project>Properties>


Sorry but the forum do not allow me to attach more than one photo per post.

Hi @George,

ok, now I see clearer. Please let me address your individual points you’re making in the order of appearance:

Basically true. However, please keep in mind that originally the main target audience for ActiveX controls were Visual Basic users back in the mid 90’s. During that time, ActiveX controls have gained remarkable foothold and were also usable of course from within MFC, CBuilder and Delphi programs, so it was only natural to add a bridge towards .Net as well for Microsoft when they published C# and VB.Net. With the .Net languages, however, it is possible to get a better ease-of-use than with ActiveX controls which is what motivated us to publish CVB.Net (see more on that in a bit).

I’m not entirely sure, but the “Foundation” reference probably referred to the Stemmer.Cvb.Foundation namespace (in the DLL of the same name) in which the functions of the CVCEdge.dll (which are also the basis for the Edge control) have been wrapped for easier integration into .Net programs. I is, however, unfortunately true that there are not yet a large number of examples available (Stemmer.Cvb.Foundation currently has only one that concerns itself with the Polarization functions). The examples under “Edge” either use the DLL directly (CSFindFirstEdge, VCEdgeDL, VCEdgeDLLSimple and VCProjection) or the Edge Control (DelphiEdgeOCX, VCEdgeOCX).

As pointed out in my earlier reply, the ActiveX controls (all of them except for CVCColor) are in fact available for both, the Win32 target architecture and for the x64 target architecture. They are just not both installed at the same time because there is no mixed installer that contains both, Win32 and x64 components (as a matter of fact, the reason why there is today no mixed installer are in fact the ActiveX controls…). So you can either use the Win32 binaries (by installing the Win32 build of :cvb:) or the x64 binaries (by installing the x64 build of :cvb:), but you’ll have to basically choose at installation time which one to use. After installing you can (and should) add the ActiveX controls to your Forms Editor’s tool box: Right click on tool box, select Choose items, wait for Visual Studio to finish scanning, go to the COM objects tab and select the ones you want to appear on your tool box:


So basically nothing has changed about that.

It is, however, true that for new projects today we strongly recommend having a look at the newer APIs (CVB++, CVB.Net and CVBpy) rather than using the ActiveX controls: These are basically - sorry for that - dated technology and we see support for them become more and more flaky in newer development environments. As a technology, ActiveX controls just do not have the relevance any more that they used to have some 20 years ago and therefore they are no longer our go-to recommendation.

P.S.: It is possible to paste more than one image into one post. I usually put them in the system’s clipboard and then just press CTRL+V in the editor:
image
I’ll rearrange your screenshots into one post - I hope that’s fine with you.

P.P.S.: One comment on the screensho of your project’s references:

  • All the AxCV*Lib references and CV*Lib references are the autogenerated OCX wrappers from tlbimp and aximp. Visual Studio did generate these for you and will always regenerate them for you, so you won’t add anything anywhere for them.
  • I am not entirely sure whether iCVCEdge is actually used in your project as you are using the ActiveX control.
  • The Stemmer.Cvb* references are references to CVB.Net.

Hello Illusive,
Thank you very much for your quick response!
Just to know how…please may you tell me what is the code to change the Edge tool searchmode from Threshold to Contrast? I am still talking about the ActiveX Edge Control.
No info in Tutorials or Doc about it
I am trying this to change the properties but it doesn’t work
axCvEdge.Searchmode =
Thank you very much
My best regards

Hi @George,

actually there’s two sample programs available for the ActiveX Edge Control, DelphiEdgeOCX and VCEdgeOCX. We unfortunately don’t have the bandwidth to write every tutorial for every language and rely on users cross-reading.

In fact, SearchMode is the property you are looking for. If you set it to SEARCHMODE_CONTRAST or SEARCHMODE_CONTRAST_SUB you are contrast-sensitive instead of value-sensitive. However, please keep in mind that when switching to contrast mode, you’ll usually need to adjust your thresholds as well becaus the contrasts are usually much lower.

If you did not change your threshold that might in fact explain why it’s not working for you. If that was not the problem, then I’d need a more detailed description of what “it doesn’t work” means.

Best regards!

Hello Illusive,
Yes I know SearchMode is a property but imagine that you want to change that property by creating a button to do it, that is I want to achieve!
As you know…I am a C# rookie :wink:
Can you help me? Thank you in advance

Following the approach from the VC excample, I would recommend to go for a drop down list (non-editable verison of the combo box). You can then

  • Simply fill it with the values of the SearchMode enum(!). Then in the SelectionChanged even you could just convert these strings back to the actual enum values by means of the System.Enum.Parse method and set it on the SearchMode property.
  • If you are after a more operator-friendly text, then build two System.Dictionary<string, string>s that map the enum values to what you want to display to the user and vice versa. Use these dictionaries to fill the box and (in the SelectionChanged even) to convert back to the enum.
  • Of course you could also use the SelectedIndex of the combo box and just cast this to an integer. As long as you add the strings strictly in the order in which they appear in the enum this is safe.

The twist with the conversion of int to enum would also work with a set of radio buttons. If you only want a non-contiguous set of the enum values (e. g. SEARCHMODE_THRESHOLD which maps to 0 and SEARCHMODE_CONTRAST which maps to 2) you could, for example, use two radio buttons only and store the associated enum value in the Tag member of the radio button and apply it in the changed event of the radio button.

Which method you use is to a great extent a matter of taste I guess.