You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

COM+ DLL在VB窗体中调用失败,寻求可行解决方案

COM+ DLL在VB窗体中调用失败的身份配置修复方案

你编写的用于ASP和PHP的COM+ DLL(VB.NET)代码如下:

Imports System.EnterpriseServices
Imports System.Runtime.InteropServices

<Assembly: ApplicationNameAttribute("NAME")>
<Assembly: SecurityRoleAttribute("Roles", True)>
<Assembly: ApplicationAccessControl(False)>
<Assembly: ApplicationActivationAttribute(ActivationOption.Server)>
<Assembly: ApplicationID("XXXX-XXXXX----")>

<ComVisible(True)>
Public Interface IAdminInterface
    Function Version() As String
    Property FormatOutput() As String
End Interface

<ProgId("NAME.Admin")>
<ComClass(Admin.ClassId, Admin.InterfaceId, Admin.EventsId)>
Public Class Admin
    Inherits ServicedComponent

    Public Const ClassId As String = "XXXX-XXXXX----1"
    Public Const InterfaceId As String = "XXXX-XXXXX----2"
    Public Const EventsId As String = "XXXX-XXXXX----3"

    {...}
End Class

在VB窗体中调用该组件时,触发以下错误:

System.Runtime.InteropServices.COMException: "The server process could not be initiated because the identity configured is not correct. Check the user's name and password.The server process could not be initiated because the configured identity is not correct. Check the user's name and password."

核心问题与修复步骤

这个错误的根源是COM+应用的身份账户配置无效,无需替换为普通DLL,按以下步骤修复:

  • 打开组件服务:按下Win+R,输入dcomcnfg并回车
  • 导航到:组件服务 > 计算机 > 我的电脑 > COM+应用程序
  • 找到代码中ApplicationNameAttribute指定的应用(即NAME),右键选择属性
  • 切换到标识选项卡:
    • 若选择的是「指定用户」,确认账户名和密码正确,且该账户拥有本地登录权限,以及启动COM+进程的权限
    • 开发环境可临时切换为「交互式用户」,方便快速测试;生产环境建议使用权限受限的专用服务账户
  • 保存设置后,右键COM+应用,选择关闭再启动,重启服务生效

验证调用

修复配置后,在VB窗体中重新通过ProgID NAME.Admin引用组件,测试调用即可正常加载。

是否需要改为普通DLL?

只有当你不需要COM+提供的事务管理、角色安全、远程激活等服务时,才需要修改为普通COM DLL(移除Inherits ServicedComponent及所有System.EnterpriseServices相关的程序集特性)。当前问题仅需修复身份配置,无需重构代码。

内容的提问来源于stack exchange,提问作者javi200482

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.29 18:30:27