如何用.NET替换VB6 Com + DLL

时间:2022-06-24 03:30:01

We have a Com+ VB6 DLL used in our asp classic application. After upgrading to IIS 6.0 and Windows Server 2003 it seems to be causing us problem. How should we replace it with .NET (2.0) functionality?

我们的asp经典应用程序中使用了Com + VB6 DLL。升级到IIS 6.0和Windows Server 2003之后,似乎导致了我们的问题。我们应该如何用.NET(2.0)功能替换它?

  • A Webservice?
  • A Com DLL in .NET?
  • .NET中的Com DLL?

  • Some other option?
  • 还有其他选择吗?

Assume re-writing the asp classic pages is out of the question.

假设重写asp经典页面是不可能的。

EDIT: If rewriting it as a com accessible assembly, won't this leave the same issues with Com+?

编辑:如果将其重写为com可访问的程序集,这不会留下与Com +相同的问题吗?

3 个解决方案

#1


It really depends on how the com dll is being used. I'm assuming that you need to keep the classic asp application otherwise you'd rewrite the whole thing.

这实际上取决于如何使用com dll。我假设您需要保留经典的asp应用程序,否则您将重写整个事情。

You don't want a webservice if the com dll is working with the session or http context of the site. I would move the com code over to a .NET Library Assembly, register it with interop (tlbimport/tlbexport) and use the interop assembly in your classic asp app to talk with the new .NET library.

如果com dll正在使用站点的会话或http上下文,则不需要Web服务。我将com代码移到.NET库程序集中,使用interop(tlbimport / tlbexport)注册它,并使用经典asp应用程序中的interop程序集与新的.NET库进行通信。

#2


This depends a lot on exactly what the COM component is doing, but the simplest option would probably be a COM library in .NET.

这很大程度上取决于COM组件正在做什么,但最简单的选项可能是.NET中的COM库。

That would likely require the least amount of changes to the calling client (asp classic app). If you setup the API to match your VB 6 COM api, it should be pretty much a drop in replacement.

这可能需要对调用客户端(asp经典应用程序)进行最少量的更改。如果您设置API以匹配您的VB 6 COM API,那么它应该是替代品。

Migrating to a webservice or some other option might be cleaner in some cases, but would require more changes to your application. Without more information, it's impossible to determine whether this would be worthwhile or not.

在某些情况下,迁移到Web服务或其他选项可能更干净,但需要对应用程序进行更多更改。没有更多信息,就无法确定这是否值得。

#3


I'm assuming that your VB6 component is using some COM+ services. If so, then I would rewrite the VB6 component in .NET as a ServicedComponent and then register it with COM+ using Regsvcs.exe.

我假设你的VB6组件正在使用一些COM +服务。如果是这样,那么我会将.NET中的VB6组件重写为ServicedComponent,然后使用Regsvcs.exe将其注册到COM +。

If your VB6 components are accessing a database (or making other long running out of apartment calls) then, as an added benefit of migrating your VB6 component(s) to .NET, you may see the elimination of performance issues when there are many concurrent requests to your components. For a great description of how and why see the Avoid Long Running Method Calls from a Single-Threaded Apartment (STA) section from the article Preserving Application Performance When Porting from MTS to COM+.

如果您的VB6组件正在访问数据库(或使其他长时间没有公寓调用),那么,作为将VB6组件迁移到.NET的额外好处,您可能会发现当并发很多时,性能问题就会消除对您的组件的请求。有关如何以及为何从“从MTS移植到COM +时保留应用程序性能”一文中从单线程单元(STA)部分看到避免长时间运行方法调用的详细说明。

#1


It really depends on how the com dll is being used. I'm assuming that you need to keep the classic asp application otherwise you'd rewrite the whole thing.

这实际上取决于如何使用com dll。我假设您需要保留经典的asp应用程序,否则您将重写整个事情。

You don't want a webservice if the com dll is working with the session or http context of the site. I would move the com code over to a .NET Library Assembly, register it with interop (tlbimport/tlbexport) and use the interop assembly in your classic asp app to talk with the new .NET library.

如果com dll正在使用站点的会话或http上下文,则不需要Web服务。我将com代码移到.NET库程序集中,使用interop(tlbimport / tlbexport)注册它,并使用经典asp应用程序中的interop程序集与新的.NET库进行通信。

#2


This depends a lot on exactly what the COM component is doing, but the simplest option would probably be a COM library in .NET.

这很大程度上取决于COM组件正在做什么,但最简单的选项可能是.NET中的COM库。

That would likely require the least amount of changes to the calling client (asp classic app). If you setup the API to match your VB 6 COM api, it should be pretty much a drop in replacement.

这可能需要对调用客户端(asp经典应用程序)进行最少量的更改。如果您设置API以匹配您的VB 6 COM API,那么它应该是替代品。

Migrating to a webservice or some other option might be cleaner in some cases, but would require more changes to your application. Without more information, it's impossible to determine whether this would be worthwhile or not.

在某些情况下,迁移到Web服务或其他选项可能更干净,但需要对应用程序进行更多更改。没有更多信息,就无法确定这是否值得。

#3


I'm assuming that your VB6 component is using some COM+ services. If so, then I would rewrite the VB6 component in .NET as a ServicedComponent and then register it with COM+ using Regsvcs.exe.

我假设你的VB6组件正在使用一些COM +服务。如果是这样,那么我会将.NET中的VB6组件重写为ServicedComponent,然后使用Regsvcs.exe将其注册到COM +。

If your VB6 components are accessing a database (or making other long running out of apartment calls) then, as an added benefit of migrating your VB6 component(s) to .NET, you may see the elimination of performance issues when there are many concurrent requests to your components. For a great description of how and why see the Avoid Long Running Method Calls from a Single-Threaded Apartment (STA) section from the article Preserving Application Performance When Porting from MTS to COM+.

如果您的VB6组件正在访问数据库(或使其他长时间没有公寓调用),那么,作为将VB6组件迁移到.NET的额外好处,您可能会发现当并发很多时,性能问题就会消除对您的组件的请求。有关如何以及为何从“从MTS移植到COM +时保留应用程序性能”一文中从单线程单元(STA)部分看到避免长时间运行方法调用的详细说明。