Page 1 of 1

ActiveX, COM, .NET et. al.

Posted: Wed Jul 01, 2015 9:24 pm
by S3ISysop
An interesting discussion about using a Microsoft based approach to dialogs
Last Updated: 2006-08-10

Eric Bisaillon

Was anyone here successful in embedding a .NET ActiveX in an XUI dialog? I was able to do it for non-.NET controls but still no luck with .NET.... I keep reading that .NET no longer supports the creation of ActiveX controls but I was wondering if anyone here was able to ultimately embed a .NET component in a XUi dialog? Any help/tips would be appreciated.

Clay Helberg

We use a .NET control for editing MathML expressions in Epic. The integration is managed by a C# COM wrapper that makes the control masquerade as an ActiveX control, which Epic can then load from a script.

One thing that might work for you: instead of trying to embed the control in a XUI dialog, can you make the .NET control create its own dialog? If so, then you can invoke it from JScript or VBScript, pass it info from Epic, let it do its thing, and then get the result before you close it. That is how our MathML control works, and it may be why we haven't had the kind of problems you mention.

One caveat though, our current implementation is not compatible with .NET 2.0, and I haven't had a chance to update it yet to see if we can make it work with .NET 2.0. It may be that it's much more difficult to do this sort of thing with the new version of .NET.

(For my money, .NET is way more trouble than it's worth. Give me Java any day of the week!)

Eric Bisaillon

Thanks for the quick response. We actually have quite a good amount of .NET code that we invoke through Epic with COM that have their own dialogs and it works well but in this situation, I was looking at embedding it in an XUI dialog to try and take advantage of the new capabilities in 5.1 and use that XUI as a toolbar and really integrating that .NET component in the Editor (as a toolbar) instead of a modal dialog (our other .NET components).

Maybe if I can figure out a way to call COM components that draw non-modal dialogs but I don't know if that can be done, maybe with the Epic .NET PIA, any experience using that here ?

Clay Helberg

Ah, I see what you're up to. Sorry, but I'm afraid my original message has exhausted my knowledge of .NET and how it works with Epic, so you'll have to find someone smarter than me to help figure this one out. :-)

Eric Bisaillon

Hey Clay, don't worry about it, thanks for your input. I'll let you know if I find a solution that works... (Why would MS remove support for ActiveX components... err....)

Brandon Ibach

Well, ActiveX was based on COM, so with .NET being the "next great thing" which replaces COM... In any case, I think Clay's initial suggestion might do the trick. That is, use C++ (ok, Clay said C#... did you mean that, Clay?) to create an ActiveX "control" that just passes all the appropriate calls on to your .NET component via COM interop.
There might be a way to achieve this directly using COM interop without having to do the C++ wrapper, but that's beyond my experience. If you wanted to try, though, I'd suggest starting with an ActiveX control that you know will work in your XUI and look at it using the OLEView tool that comes with Visual Studio 6. That will let you see which COM interfaces are implemented by the control. Then, you just need to make sure that your .NET component provides those same interfaces. This will probably not be very straightforward, but it seems like it should be possible.