Call COM object from classic ASP

江枫思渺然 提交于 2019-12-04 02:16:14

问题


How to call COM object from classic ASP? I tried hard but cannot find a good tutorial. Any recommendations?

I am using C# in classic ASP.


回答1:


If you're using JavaScript:

var obj = new ActiveXObject("Some.Object")

For example, see this page:

  • http://www.webreference.com/js/column55/activex.html

This assumes that "Some.Object" has been registered as a COM object (for example, using "regsvr32 /register SomeObject.dll").

For further reading, O'Reilly had a decent book on this and you might consider reading this sample chapter:

  • http://oreilly.com/catalog/devaspcom2/chapter/ch10.html

or this tutorial:

  • http://www.15seconds.com/Issue/980930.htm



回答2:


To instantiate a COM object in classic ASP:

Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")

COM objects are registered (in the registry) with a name known as the ProgId, which is ("ADODB.Recordset") in the above snippet.

Heres's a tutorial: Using COM Objects

Update, in response to posters comments: If you are creating a .NET assembly, then you will need to run regasm.exe on it to create the necessary information to allow COM clients to create .NET Framework classes.

The regasm.exe tool works by reading the declaration of your class, and in particular the class-level attributes GuidAttribute and ProgID as shown here:

using System.Runtime.InteropServices;

[GuidAttribute("581C28BD-E701-4AC1-BD75-0979BCEEC91E"),
ProgId("WordAddin1.Connect")]
public class Connect : Object, Extensibility.IDTExtensibility2
{

}


来源:https://stackoverflow.com/questions/1183943/call-com-object-from-classic-asp

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