Hi everyone,
While you can do COM-visible components in .NET, you unfortunately cannot do
OCX (ActiveX) *controls*. OCX/ActiveX involves a little bit more than a
non-visual COM components, namely a set of pre-defined interfaces which
should be properly implemented by the control to cover the communication
between the control and its site. For example, you can take a look at
interfaces such as IOleClientSite and IOleWindow (the spelling might be not
100% correct, it's been more than a year ago I dealt with these).
From what I remember, in early versions of the framework, the
System.Windows.Forms.Control class used to implement these interfaces, but
at some point Microsoft decided not to support them anymore.
As a workaround, you can use a so-called "shim control". This is a small
ActiveX control written in C++ which should be available free of charge in
the "Files" section of the "vsnetaddin" Yahoo group. This shim control is
used by add-in developers to host .NET Windows Forms controls as ActiveX
controls inside IDE's tool windows.
If your C# code is not UI-related, you can indeed compile and register it as
a COM-visible assembly, and then to create the visual part in, say, Visual
Basic 6, and to reference the C#-written COM DLL from the VB6 project.
--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx
"Abubakar" <Ab******@discussions.microsoft.com> wrote in message
news:80**********************************@microsof t.com...
But you will have to give it a try becuz there is no other way. The
probability of it not running is very low. I would say you give it a try,
I bet it'll work for you :-)
Abubakar.
http://joehacker.blogspot.com
"Andrey" wrote:
Abubakar wrote: AFAIK There is no way to write an ocx in c# or vb. However you can
easily "expose" your managed usercontrols or libraries as com components to
be used by com enabled environments. To use this feature of .net please see
the documentation of tools "Regasm.exe" and "Tlbexp.exe" and also read
"strong named" assemblies in .net. Its all nicely documented in msdn and you
shouldnt have any difficulty in doing this after reading the docs.
Actually i've read an article where they say this feature is not
supported by Microsoft and an assembly is not guaranteed to work this way, may or may not.
Hope that helps.
Abubakar.
http://joehacker.blogspot.com
"smeagol" wrote:
>Hi, is possible to create an OCX with .NET?
>I need to use a control (user control) in Visual Fox Pro, but the old
fox>doesn't accept usercontrols.
>Any help are welcome
>