简体   繁体   中英

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.

For the sake of simplicity, I have a test dll which has two classes in it:

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.

I have registered the dll using >RegAsm.exe /codebase /tlb

And then I load the dll using set obj = CreateObject("MyAsmNamespace.MyClass")

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)

I looked in IL DASM, and MySecondClass is in the assembly, but not listed under a namespace. Looking in regedit, I can see that MyAsmNamespace.MyClass is registered, but I cannot find MySecondClass anywhere.

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?

经过几天的研究,如果该类未放置在命名空间中,则我找不到使用CreateObject引用程序集中的类的方法。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM