无法为指定的ProgID创建对象实例(WIA.CommonDialog) [英] Failed to create an object instance for the specified ProgID (WIA.CommonDialog)

查看:237
本文介绍了无法为指定的ProgID创建对象实例(WIA.CommonDialog)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正试图允许用户使用Silverlight XAP从浏览器从远程服务器上以较高的信任度在浏览器中运行文档扫描,并收到以下错误消息:

We are trying to allow users to scan documents using a Silverlight XAP running in-browser with elevated trust, from a remote server, and are getting the following error:

Silverlight应用程序中未处理的错误未能为指定的ProgID创建对象实例.

Unhandled Error in Silverlight Application Failed to create an object instance for the specified ProgID.

失败在以下行:

Dim CommonDialog = AutomationFactory.CreateObject("WIA.CommonDialog")

Application.Current.HasElevatedPermissions AutomationFactory.IsAvailable 均返回True.

Application.Current.HasElevatedPermissions and AutomationFactory.IsAvailable both return True.

我可以成功创建不安全的ActiveX控件的实例,例如Scripting.FileSystemObject:

I can successfully create an instance of unsafe ActiveX controls, e.g. Scripting.FileSystemObject:

Dim fso = AutomationFactory.CreateObject("Scripting.FileSystemObject")

从远程服务器上的生产环境运行时,代码失败.从本地主机从ASP.NET开发服务器运行时,代码成功,并且在调用CommonDialog.ShowAcquireImage()时显示WIA扫描对话框.

The code fails when running from the production environment on the remote server. When running from the ASP.NET Development server from localhost, the code succeeds, and the WIA scanning dialog is shown when calling CommonDialog.ShowAcquireImage().

我该如何解决? (也许有关WIA的某些特定内容会阻止它以这种方式使用?)我可以采取哪些步骤尝试对其进行调试?

How can I resolve this? (Is there perhaps something specific about WIA that prevents it from being used this way?) What steps can I take to try and debug this?

更新

当我尝试打开生成的Silverlight测试页(通过file协议)时,出现相同的错误.

When I try to open the generated Silverlight test page (via the file protocol), I get the same error.

更新2

进程监视器显示AllowLaunchOfElevatedTrustAppsAllowElevatedTrustAppsInBrowser键正在成功查询.

Process Monitor shows that the AllowLaunchOfElevatedTrustApps and AllowElevatedTrustAppsInBrowser keys are being successfully queried.

更新3

在保护模式关闭的情况下,代码有效.

With Protected Mode turned off, the code works.

推荐答案

The MSDN reference states that to enable COM Interop inside the browser, you must

  1. 设置注册表项HKEY_LOCAL_MACHINE\Software\Microsoft\Silverlight\(或在x64 HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Silverlight\上) AllowElevatedTrustAppsInBrowser DWORD 0x0000001

  1. Set Registry Key HKEY_LOCAL_MACHINE\Software\Microsoft\Silverlight\ (or on x64 HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Silverlight\) AllowElevatedTrustAppsInBrowser DWORD 0x0000001

检查您的组策略未禁用AllowInstallOfElevatedTrustAppsAllowLaunchOfElevatedTrustApps

Check your group policy has not disabled AllowInstallOfElevatedTrustApps and AllowLaunchOfElevatedTrustApps

对.xap签名

将证书安装到Trusted Application Store(请参阅屏幕截图说明如何)

Install cert to Trusted Application Store (see screenshots illustrating how)

此外,您还必须

  1. 配置为浏览器外"应用程序(即使您没有运行浏览器外")

  1. configure as Out of Browser Application (even if you are not running Out of Browser)

在调用ComAutomationFactory.CreateObject之前,应检查

before calling the ComAutomationFactory.CreateObject you should check for Application.Current.HasElevatedPermissions and AutomationFactory.IsAvailable

请注意,来自 http://localhost

note that Elevated Permission testing from http://localhost and http://127.0.0.1 is not reliable test, as Silverlight runtime makes exception for these two URLs. Instead use file://.

故障排除

  1. 使用ProcMon验证是否正在读取AllowElevatedTrustAppsInBrowser注册表项

将调试器附加到Silverlight(请参见屏幕截图)

Attach Debugger to Silverlight (see screenshots)

MSIE保护模式设置也可能会对Silverlight应用程序是否可以使用提升的权限"运行产生不利影响.尝试使用其他保护模式设置运行.

MSIE Protected Mode settings can also adversely affect whether a Silverlight application can run with Elevated Permissions. Try running with different Protected Mode settings.

这篇关于无法为指定的ProgID创建对象实例(WIA.CommonDialog)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆