views:

128

answers:

2

As the title points out, what I want to do is use an .OCX control (namely AxShockwaveFlashObject) in a C# console application. I assume that it's possible, as I've seen it done before. but it was C++, and I don't even sure it was .NET. So, is it possible? and if so, how?

Thanks, Leeron

+1  A: 

It depends what do you want to use it for. You can have forms in console applications (they can be invisible if you want), and it's straightforward to use the Visual Studio forms designer to put an ActiveX control on a form.

Tim Robinson
Do you think using a console application with a hidden form instead of a windows application will have a positive impact on performance?
Leeron
An impact on performance compared to what?
Tim Robinson
Compared to running the same form (the one we set as hidden in the console application) in a Windows Forms Application.
Leeron
The same: there's no real differences between console apps and GUI apps. Console apps get a console created automatically on startup, GUI apps don't.
Tim Robinson
+1  A: 

An OCX file is just a native DLL with a different file extension. You should be able to interop with it without creating any UI, unless the control itself relies on creation of a window handle, in which case the hidden form approach would be best.

If you do not already have the interop DLLs (which expose the managed interface for the COM component), you can generate them using the commandline aximp (Windows Forms ActiveX Control Importer) tool or by dragging the OCX into the Visual Studio Toolbox.

Ed Noepel