我需要以下方面的意见:
我使用 .NET 创建了一个 DLL 文件。此 DLL 文件旨在用于 ASP Classic和 ASP.NET 应用程序。我创建了一个安装和部署包,并将解决方案的输出添加到 GAC文件夹。之后,在 ASP Classic 中创建实例就不起作用了。我不确定它是否可以从 GAC 文件夹加载。
或者,我通过添加从 ServiceComponent 继承和其他必要的更改来将此 .dll 转换为 COM,但在客户端上注册为 COM 时,它会引发错误:
one or more files do not contain components or type libraries
我错过了什么?我该怎么做才能使 DLL 文件可以被 ASP Classic 和 ASP.NET 使用?
最佳答案
步骤...
Visual studio: start a new class library
Properties > Application : make assembly COM-Visible
Properties > Build : Register for COM interop
Properties > Signing: Sign the assembly
然后构建项目。
以管理员身份启动 Visual Studio 命令提示符(在操作系统菜单中查找此命令提示符):
cd <path to your dll>
RegAsm /register <name of your dll>.dll /tlb:<name of your dll>.tlb
gacutil -i <name of your dll>.dll
IISreset (not a bad idea to reset after these stepts in your development environment because the dll gets cached)
这应该可以解决问题...
最后的建议...从头开始构建一个新项目(只是一个 Hello World)并将上述步骤融入您的 DNA 中。这是...它起作用的领域之一 - 不,它不起作用 - 现在它再次起作用发挥了重要作用;-)
关于asp.net - 在客户端计算机上注册 .NET COM DLL 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20878728/