简体   繁体   English

在Windows 8.1上调用COM +组件时出现自动化错误

[英]Automation Error when calling COM+ component on Windows 8.1

I have a legacy VB6 application that makes calls to a COM+ component written in C# (targeting .NET Framework v2) for TCP/IP communications. 我有一个旧版VB6应用程序,该应用程序调用以C#编写的COM +组件(面向.NET Framework v2)进行TCP / IP通信。

This mode of operation has worked across various operating systems and has been successfully deployed to Windows XP, Vista and 7 environments. 这种操作模式已在各种操作系统上工作,并已成功部署到Windows XP,Vista和7环境中。

I've just started testing the software in Windows 8.1 and when the VB6 application tries to make calls to the COM+ component it reports "automation error". 我刚刚开始测试Windows 8.1中的软件,当VB6应用程序尝试调用COM +组件时,它报告“自动化错误”。 These kinds of errors in the past have been due to the COM+ registration failing and are quickly rectified by manually registering the COM+ component using regsvcs.exe . 过去,这些错误是由于COM +注册失败而引起的,可以通过使用regsvcs.exe手动注册COM +组件来快速纠正。

The software is installed by and MSI which also runs a script which calls regsvcs.exe to register the COM+ component. 该软件由MSI安装,MSI还运行一个脚本,该脚本调用regsvcs.exe来注册COM +组件。 For Win 8.1 I had to change the path of regsvcs.exe from: 对于Win 8.1,我必须从以下位置更改regsvcs.exe的路径:

C:\Windows\Microsoft.NET\Framework\v2.0.50727

To: 至:

C:\Windows\Microsoft.NET\Framework\v4.0.30319

I tested this installer on both Win 7 and Win 8.1. 我在Win 7和Win 8.1上都测试了此安装程序。 On Win 7 the COM+ calls work fine. 在Win 7上,COM +调用工作正常。 The problem I'm having with Win 8.1 is that the COM+ component seems to be registered properly, however the calls to the component still fail. 我在Win 8.1上遇到的问题是COM +组件似乎已正确注册,但是对该组件的调用仍然失败。 Everything looks fine in Component Services and the COM+ application starts when the VB6 call is made, but the automation error is returned and the call fails. 进行VB6调用时,组件服务中的所有内容看起来都很好,并且COM +应用程序启动,但返回了自动化错误,并且调用失败。

Note: The Win 7 and 8.1 environments I'm testing on are 64 bit. 注意:我正在测试的Win 7和8.1环境是64位。

It seems that something relating to Component Services and COM+ applications has changed between Windows 7 and Windows 8.1, but I can't seem to find a solution. 在Windows 7和Windows 8.1之间,似乎与组件服务和COM +应用程序有关的某些事物已更改,但我似乎找不到解决方案。

Has anyone experienced something similar or any pointers on what the problem might be? 有没有人遇到过类似的经历或关于可能出现问题的任何指示?

After many hours of trying different things, I've found a solution. 经过许多小时的尝试,我找到了解决方案。 I had to enable .NET Framework 3.5 (including Framework 2) and change the path to regsvcs.exe back to C:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727 . 我必须启用.NET Framework 3.5(包括Framework 2),并将regsvcs.exe的路径regsvcs.exeC:\\Windows\\Microsoft.NET\\Framework\\v2.0.50727

Now after re-installation the calls to the COM+ component are working. 现在,重新安装后,对COM +组件的调用即可正常工作。 Still unsure as to what the difference is between using this utility from the v2 folder and the v4 folder. 仍不确定使用v2文件夹和v4文件夹中的此实用程序有什么区别。

As an aside, while trying to enable .NET Framework 3.5 using the 'Turn Windows Features On and Off' feature in Programs and Features, I kept getting the error 0x800F0906 . 0x800F0906 ,在尝试使用“程序和功能”中的“打开和关闭Windows功能”功能启用.NET Framework 3.5时,我一直收到错误0x800F0906

I ended up having to install it from the mounted Windows 8.1 ISO using the following command: 我最终不得不使用以下命令从已安装的Windows 8.1 ISO进行安装:

dism /online /Enable-Feature /FeatureName:NetFX3 /All /Source:E:\Sources\SxS /LimitAccess

Where E:\\ is the drive letter of the mounted ISO. 其中E:\\是已安装ISO的驱动器号。

The process I followed was described here: https://yellowduckguy.wordpress.com/2012/10/19/windows-8-fix-enable-feature-net-3-5-error-0x800f0906/ 我遵循的过程在此处进行了描述: https//yellowduckguy.wordpress.com/2012/10/19/windows-8-fix-enable-feature-net-3-5-error-0x800f0906/

I facing exactly the same problem like you, i've made a .NET COM Interop DLL for calling from Vb6 . 我遇到了与您完全相同的问题,我制作了一个.NET COM Interop DLL以便从Vb6进行调用。 My software working on all Windows version except one day i found some computer using Windows 8 having trouble when run my software. 我的软件适用于所有Windows版本,但有一天除外,我发现某些使用Windows 8的计算机在运行软件时遇到问题。 The error i got is Automation Error. 我得到的错误是自动化错误。

After a research, i've found that if we use the .NET version v4.0.30319 on Window 8 to register our .NET 2.0-3.5 assembly. 经过研究,我发现如果我们在Window 8上使用.NET版本v4.0.30319来注册我们的.NET 2.0-3.5程序集。 It may not work, i don't know why but may be the compatibility of different .NET version or a new bug from Microsoft. 可能不起作用,我不知道为什么,但是可能是不同.NET版本的兼容性或Microsoft的新错误。 (i know that .NET 4.0 can run .NET 2.0 assembly but don't know why there are some exception on Window 8). (我知道.NET 4.0可以运行.NET 2.0程序集,但不知道为什么Window 8上会有一些异常)。

So the best solution for me now is : 所以现在对我来说最好的解决方案是:

1) Turn on .NET 3.5 on Window 8 ( this solution is time consuming because you will need to ship the Windows 8.1 ISO within your installer) 1)在Windows 8上打开.NET 3.5(此解决方案非常耗时,因为您需要在安装程序中附带Windows 8.1 ISO)

2) Build two target version of .NET framework for your App. 2)为您的App构建两个目标版本的.NET框架。 So if your customer using Window 8 the installer will install .NET 4.0 app version. 因此,如果您的客户使用Window 8,则安装程序将安装.NET 4.0应用程序版本。 If below Window 8 then install .NET 3.5 version. 如果在Window 8以下,则安装.NET 3.5版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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