Creating an OCX with .NET

S

smeagol

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
 
A

Andrey

smeagol said:
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

There should be only a nasty way to perform that in .NET - it's just not suited for that,
but why don't you want to use something more "ActiveX-friendly", like VC++ 6.0 or VB or even Delphi?
 
S

smeagol

I had my code made in C# and is very large.. :(

Andrey said:
There should be only a nasty way to perform that in .NET - it's just not suited for that,
but why don't you want to use something more "ActiveX-friendly", like VC++ 6.0 or VB or even Delphi?
 
G

Guest

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.

Hope that helps.

Abubakar.
http://joehacker.blogspot.com
 
A

Andrey

Abubakar said:
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.
 
D

Dmitriy Lapshin [C# / .NET MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top