[英]ActiveX component can't create object: what happens to classes that don't have a namespace when the dll is registered?
I have a fairly complex dll which contains two namespaces, as well as a few classes that do not belong to a namespace at all. 我有一个相当复杂的dll,其中包含两个名称空间,以及一些根本不属于名称空间的类。
For the sake of simplicity, I have a test dll which has two classes in it: 为了简单起见,我有一个测试dll,其中包含两个类:
namespace MyAsmNamespace{
public MyClass{
public int doSomething(){ return 1;}
}
}
and 和
public MySecondClass{
public int doSomethingElse(){ return 2;}
}
I am trying to use objects from this dll within a classic ASP page, using CreateObject. 我正在尝试使用CreateObject在经典ASP页面中使用此dll中的对象。
I have registered the dll using >RegAsm.exe /codebase /tlb
我已经使用
>RegAsm.exe /codebase /tlb
注册了dll
And then I load the dll using set obj = CreateObject("MyAsmNamespace.MyClass")
然后我使用
set obj = CreateObject("MyAsmNamespace.MyClass")
加载dll。
Now the classes with namespaces specified work just fine, but for the class that doesn't have a namespace, I don't know what to do. 现在,指定了名称空间的类可以正常工作,但是对于没有名称空间的类,我不知道该怎么做。 I tried
set obj = CreateObject("MySecondClass")
, but that doesn't work (I get an ActiveX Component Can't Create Object error) 我试过
set obj = CreateObject("MySecondClass")
,但这不起作用(我收到一个ActiveX组件无法创建对象错误)
I looked in IL DASM, and MySecondClass is in the assembly, but not listed under a namespace. 我查看了IL DASM,MySecondClass在程序集中,但未在命名空间下列出。 Looking in regedit, I can see that MyAsmNamespace.MyClass is registered, but I cannot find MySecondClass anywhere.
在regedit中查看,我可以看到MyAsmNamespace.MyClass已注册,但是在任何地方都找不到MySecondClass。
Does MySecondClass have to be in a namespace to be referenced in classic asp or is there a default namespace it becomes a part of? MySecondClass是否必须在经典ASP中引用的命名空间中,还是默认的命名空间成为其中的一部分?
经过几天的研究,如果该类未放置在命名空间中,则我找不到使用CreateObject引用程序集中的类的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.