在 Windows Server 2003 上从 Web CGI 脚本执行 .net 应用程序时出现 InteropServices COMException

发布于 2024-07-22 01:28:11 字数 1885 浏览 4 评论 0原文

免责声明:我对 .net 和 COM 完全一无所知。

我有一个供应商的应用程序,似乎是用 .net 编写的,我正在尝试用 Web 表单(一个 cgi-bin Perl 脚本),这样我最终可以从单独的计算机启动该供应商的应用程序。 我使用的是 Windows Server 2003 R2 SE SP1 系统,我使用 Apache 2.2 作为 Web 服务器,使用 ActivePerl 5.10.0.1004 作为 cgi 脚本。 我的 cgi 脚本使用 Perl 反引号运算符调用驻留在同一台计算机上的供应商应用程序。

...
$result = "Result: " . `$vendorsPath/$vendorsExecutable $arg1 $arg2`;
...

现在我只是在服务器计算机上本地运行 IE Web 浏览器并访问“http://localhost/ cgi-bin/myPerlScript.pl”。 供应商的应用程序失败并记录一条调试消息,其中包括以下堆栈跟踪(我更改了几个名称,以免泄露供应商的身份):

...
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x80043A1D): 0x80040154 - Class not registered
   --- End of inner exception stack trace ---
   at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
   at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters)
   at VendorsTool.Engine.Core.VendorsEngine.LoadVendorsServices(String fileName, String& projectCommPath)
...

当我使用确切的服务器计算机上的 Windows 命令行运行供应商应用程序时cgi 脚本传递的相同参数运行得很好,因此通过 Web 脚本调用他们的应用程序会导致问题。 这个问题可能与安全相关,因为整个过程在 Windows XP Pro 计算机上运行得很好(命令行和 Web 调用)。 实际上,我在那里开发了我的 Web 脚本,并在尝试将其移至 Windows Server 2003 计算机之前让它完全正常工作。 那么,Windows Server 2003 计算机有何不同之处,会阻止 Web CGI 脚本成功执行供应商的 .n​​et 应用程序呢?

我能否以某种方式解决此问题以使其在我的服务器上正常工作,或者供应商是否必须对其 .net 应用程序进行更改并发布新版本? 我可能是世界上唯一尝试从单独的程序执行该供应商的应用程序的人,因此,如果有一个我可以在我的服务器计算机上自行实现的解决方法,我不想用这个问题来打扰供应商。 另外,我有点着急,不想等待 4 或 6 个月供应商修复并部署新版本。

感谢您提供的任何建议。

Disclaimer: I'm completely clueless about .net and COM.

I have a vendor's application that appears to be written in .net and I'm trying to wrap it with a web form (a cgi-bin Perl script) so I can eventually launch this vendor's app from a separate computer. I'm on a Windows Server 2003 R2 SE SP1 system and I'm using Apache 2.2 for the web server and ActivePerl 5.10.0.1004 for the cgi script. My cgi script calls the vendor's app that resides on the same machine using the Perl backtick operator.

...
$result = "Result: " . `$vendorsPath/$vendorsExecutable $arg1 $arg2`;
...

Right now I'm just running IE web browser locally on the server machine and accessing "http://localhost/cgi-bin/myPerlScript.pl". The vendor's app fails and logs a debug message that includes the following stack trace (I changed a couple names so as to not give away the vendor's identity):

...
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x80043A1D): 0x80040154 - Class not registered
   --- End of inner exception stack trace ---
   at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
   at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters)
   at VendorsTool.Engine.Core.VendorsEngine.LoadVendorsServices(String fileName, String& projectCommPath)
...

When I run the vendors app from the Windows command line on the server machine with the exact same arguments that the cgi script is passing it runs just fine, so there's something about invoking their app via the web script that is causing a problem. This problem is likely security related because the whole thing runs just fine on a Windows XP Pro machine (both command line and web invocation). I actually developed my web script there and got it completely working there before I tried moving it to the Windows Server 2003 machine. So what's different about the Windows Server 2003 machine that would keep the vendor's .net app from being executed successfully by a web cgi script?

Can I fix this problem somehow to make it work on my server or will the vendor have to make a change to their .net app and ship out a new version? I'm probably the only person in the world who is trying to execute this vendor's app from a separate program, so I hate to bother the vendor with the issue if there's a workaround that I can implement myself here on my server machine. Plus, I'm in kind of a hurry and I don't want to wait 4 or 6 months for the vendor to put in a fix and deploy a new version.

Thanks for any advise you can give.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

谎言月老 2024-07-29 01:28:11

在我看来,你有权限问题。 您的 .NET 应用程序似乎尝试使用 COM 对象,但没有足够的权限来执行此操作。

每个COM对象(COM服务器)都有启动/激活和访问权限(只需启动dcomcnfg并查看一些众所周知的应用程序的DCOM配置)。 对于dcomcnfg(组件服务),您不仅可以查看还可以更改此权限(选择一个应用程序并在上下文菜单中打开属性对话框。然后选择“安全”选项卡,在“启动和激活权限”块,然后单击“编辑”)。 典型的问题是 INTERACTIVE 用户对大多数 COM 对象具有启动/激活权限,但作为服务运行的进程不是该组的成员。 因此,您必须通过向某个帐户(由您的 Apache Web 服务器使用)或组(如 IIS_IUSRS )授予具有交互用户的相同启动权限来自定义权限。 此权限信息将保存在 HKEY_CLASSES_ROOT\AppID 项的子项中(请参阅二进制 AccessPermission 注册表值)。

为了识别导致问题的 COM 对象,我建议您使用 Process Monitor(参见 http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx)和Process Explorer(请参阅http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx)。 进程监视器可以帮助您准确找出您的程序($vendorsExecutable)尝试启动哪些其他进程。 最后一次访问 HKEY_CLASSES_ROOT 中的一个用于启动 COM 对象。 你会发现它是哪个进程。 不要忘记在具有完全管理权限的帐户下启动此工具(在服务器上通常不存在此类问题)。 要更快地找到您需要的信息,请使用进程名称过滤器和进程监视器的搜索功能。

如果您第一次做这样的工作,它可能看起来非常复杂。 这并不容易,但一切都有明确的逻辑,我确信您可以解决这个问题。

It seems to me that you have permission problem. It looks like your .NET application try to use a COM object and it has not enough permission to do this.

Every COM object (COM server) has launch/activation and access permission (just start dcomcnfg and look at DCOM configuration of some well known Applications). With respect of dcomcnfg (Component Services) you can not only see but also change this permissions (select an application and open properties dialog in the context menu. Then choose "Security" tab, choose Customize in the "Launch and Activation Permission" block and then click "Edit"). Typical problem is that INTERACTIVE users have launch/activation permission to the most COM objects, but processes running as service are not a member of this group. So you have to customize permission by granting for an some account (used by your Apache web server) or a group (like a IIS_IUSRS) the same launch permission which has INTERACTIVE users. This permission information will be saved in a subkey of the HKEY_CLASSES_ROOT\AppID key (see binary AccessPermission registry value).

To identify the COM object which makes problem I'll recommend you Process Monitor (see http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx) and Process Explorer (see http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx). Process Monitor can helps you to find out exactly which other processes your program ($vendorsExecutable) try to start. One from the last accesses to HKEY_CLASSES_ROOT are used to start a COM object. You will find out which process it is. Don't forget to start this tools under an account with full administrative rights (on a server such problem typically not exist). To find the information which you need more quickly use filter to a process name and searching features of Process Monitor.

If you do such work at the first time it can look very complex. It is not easy, but everything have well defined logic and I am sure, that you solve this problem.

玻璃人 2024-07-29 01:28:11

请告诉我这是否有帮助:您收到“0x80040154(类未注册)”错误消息当您注册 ATL 服务器时

根据供应商开发其应用程序的工具,这可能是由于 DLL 注册而引起的,而该 DLL 实际上并未在您的 Windows Server 2003 上注册。

Please tell me if this helps: You receive a "0x80040154 (Class not registered)" error message when you register an ATL server

Depending on which tools the vendor has developed his application, it might be caused because of a DLL registration, which is actually not registered on your Windows Server 2003.

梦里南柯 2024-07-29 01:28:11

典型的原因是您没有安装先决条件。 很难说是哪个,因为 COM 类被许多应用程序使用。

找出丢失的类的一种方法是 sysinternals 工具 进程监视器 。 它可用于监控注册表的使用情况。 这可以帮助您准确跟踪脚本尝试加载的类。 命名的 COM 类驻留在其下

HKEY_LOCAL_MACHINE\SOFTWARE\Classes

,并且它们的底层 GUID 条目位于其中。

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID

如果 Apache 正在那里查找条目但没有找到它,则该条目可能是 perl 脚本丢失的 COM 类。

The typical cause would be that you did not install a prerequisite. It's hard to say which, because COM classes are used by so many applications.

One way to find out the missing class is the sysinternals tool process monitor. It can be used to montior registry usage. This helps you track exactly what class the script is trying to load. Named COM classes reside under

HKEY_LOCAL_MACHINE\SOFTWARE\Classes

and their underlying GUID entry is in

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID

If Apache is looking for an entry there but doesn't find it, that might be the COM class the perl script is missing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文