LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

importing .net controls into CVI through .net interop

I am trying to use the CVI ActiveX control container wizard to import COM or .net interop-ed COM controls into the UIR editor. I have two questions.

1) for straight COM controls, I found that more than half the UI controls find using Create->ActiveX function of the UIR editor doesn't work. Those are commercial controls from various company like Microsoft etc ranging from imagelist box, edit controls to graph control etc. The return error just show a popup saying "ActiveX control error". Is there way to find out what really went wrong - and further how to fix this so the control can be brought in?

2) for .net controls I have found an article describing how to expose .net control to have COM interface. I tr
ied it with CVI and also doesnt work. What does CVI ActiveX control container looks for in order to determine the Activex Control in question is containable? The article is from CodeProject and is named "Exposing Windows Form Controls as ActiveX controls" by Morgan Skinner. Enclosed is his code for testing. The example here shows a C# control converted to carry a ActiveX interface, and I used this to test the CVI ActiveX Control Container wizard.
0 Kudos
Message 1 of 5
(3,714 Views)
Hello


1) I tried using the controls you described on XP Pro with CVI 7.1 and I did not have any problems. Can you describe the steps that you took so that I can reproduce the problem? What version of CVI are you using?

2) I tried using the Windows Form control from VB 6 and Visual C++ and basically got the same type of errors. The author of the article had caveats in there that mentioned this technique only worked with .NET beta 2 and might be removed once the product was officially available. I have a Microsoft KB here that mentions this technique is not supported with .NET 1.0 and 1.1. A similar article by Chris Sells here describes this technique to be unsupported, as well as this blog here. This was not designed to be used in a complete backwards compatible manner and unless explicit support is added for this kind of functionality, Windows Form controls will not work with most of the popular ActiveX containers out there.

I am interested to know why you would require something like this. Are you trying to use the .NET class libraries from CVI?

Hope this clears things up

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 2 of 5
(3,714 Views)
Thanks very much for the insight, it is very helpful.

Checking on my test setup, the code is tried on CVI 6.0 with .net 1.1 with beta 2.0 patched on it. Do you know if it may be issue with CVI 6.0 or an faulty installation of .net beta2?

In all case your concern is valid in the sense that if Microsoft decided to pull out this feature in final release my design is busted even if I can get it to work now. Do you know any techniques to expose .net methods back in ActiveX/COM forms?

I am exploring using C++.net/C# controls and expose in ActiveX because we have some vs.net license and but no visual studio 6 compilers in sight. This gives us a bit of the problem trying to make conventional ActiveX control as Microsoft dropped lots of MFC support in their n
ewer products. Can I use CVI to make custom controls like a fancy slider bar, color map or imagelist box etc? Is so what is the technique?
0 Kudos
Message 3 of 5
(3,714 Views)
I think the beta that the guy from code project and chris sells are referring to was the beta for .NET 1.1, not 2.0. Which means that currently for the official .NET 1.1 release, this is not supported.

You might be able to find some hacks online on how to do this, but in general, creating Windows Form controls and trying to use them via ActiveX might not lend to a good user experience. There are several new behaviors and features that make using Windows Form controls really great. Trying to expose those same features to customers using your Windows Form controls via ActiveX will cause nothing but pain.
As far as I can tell, Microsoft is still adding functionality to MFC and has been extending it with each release. Can you provide some more in
formation about what you mean by dropped MFC support? Check out this blog for whats new for C++ in Whidbey.

You can still make conventional ActiveX controls using Visual C++ .NET. With Visual Studio 2003, there were extensions added to C++ to allow it to make use of the .NET Framework class libraries. But you can still continue compiling and building applications you used to be able to using Visual Studio 6.0. This means you can still use ATL, MFC, WTL with C++ and not even use .NET. This is termed as unmanaged C++. When you start making use of the .NET class libraries from C++, that would be using managed C++ and that is when you would need to make use of those C++ extensions for .NET. So even though all the literature calls it C++.NET, you can still use C++ and not really use .NET. The main distinction is between managed and unmanaged C++. I didnt know if you knew this already, but I just wanted to clarify
this just in case.

Bilal
Bilal Durrani
NI
0 Kudos
Message 4 of 5
(3,714 Views)
Due to some licensing issues I am using Visual C++/C# express 2005. Can you confirm if these techniques will work on these compiler versions with CVI. If changes are needed, what changes have to be done to get ActiveX control recognized by CVI 6.0?
0 Kudos
Message 5 of 5
(3,714 Views)