Building an OCX with VS.NET?

核能气质少年 提交于 2019-12-06 05:28:53

问题


What happened to OCX's? Are they no longer possible to create with the latest tools?

I need to create an ActiveX control that I can place in Word, PowerPoint and Excel documents. If I use VS.NET, I can only create a UserControl DLL with COM Interop, but I don't think I can add that using the "More Controls" toolbox of PowerPoint's Developer Tab.

What would you do?


回答1:


Yes, you can still create them. But you can't create an OCX with a .NET language. Need to be unmanaged C++ (or VB). The DLLs with COM interop you can create in C# or VB.NET are just .NET objects that are invoked via CCW.




回答2:


You can still use .NET to create ActiveX components. However, this is experimental and not recommended. If you still want to try it you can find information in the blog of Andrew Whitechapel:

Using Managed Controls as ActiveX Controls

But as Andrew says:

This seems to work OK for Excel (with the very limited testing I've done), partly works with PowerPoint, but fails miserably with Word.

So if you don't want to spend a lot of time debugging strange errors I would recommend you to use the old VB 6.0 and Visual Studio 6.0 to build you ActiveX components.




回答3:


Use a C++ or VB compiler which can target native code + ActiveX.




回答4:


Depending on what you need to do, an Add-in may be more appropriate than an OCX, and you can certainly create those with .NET. You should also look at the Visual Studio Tools for Office, not as a direct replacement for an OCX, but only to understand the new capabilities. It may show you new approaches to the problems you're now solving with an OCX.



来源:https://stackoverflow.com/questions/363787/building-an-ocx-with-vs-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!