无法为指定的 ProgID (WIA.CommonDialog) 创建对象实例
Failed to create an object instance for the specified ProgID (WIA.CommonDialog)
我们正在尝试允许用户使用 Silverlight XAP 运行 在浏览器中以高信任度从远程服务器扫描文档,但出现以下错误:
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 都 return 正确。
我可以成功创建不安全 ActiveX 控件的实例,例如Scripting.FileSystemObject
:
Dim fso = AutomationFactory.CreateObject("Scripting.FileSystemObject")
当 运行 来自远程服务器上的生产环境时,代码失败。当 运行 从本地主机的 ASP.NET 开发服务器时,代码成功,调用 CommonDialog.ShowAcquireImage()
.
时显示 WIA 扫描对话框
我该如何解决这个问题? (是否有关于 WIA 的特定内容阻止以这种方式使用它?)我可以采取哪些步骤来尝试调试它?
更新
当我尝试打开生成的 Silverlight 测试页面(通过 file
协议)时,我遇到了同样的错误。
更新 2
进程监视器显示正在成功查询 AllowLaunchOfElevatedTrustApps
和 AllowElevatedTrustAppsInBrowser
键。
更新 3
关闭保护模式后,代码可以正常工作。
MSDN reference 声明要在浏览器中启用 COM Interop,您必须
设置注册表项HKEY_LOCAL_MACHINE\Software\Microsoft\Silverlight\
(或在 x64 上HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Silverlight\
)AllowElevatedTrustAppsInBrowserDWORD
0x0000001
检查你的组策略没有禁用AllowInstallOfElevatedTrustApps
和AllowLaunchOfElevatedTrustApps
签署 .xap
将证书安装到受信任的应用程序商店(参见 screenshots 说明)
此外,您必须
配置为浏览器外应用程序(即使您没有运行浏览器外)
在调用 ComAutomationFactory.CreateObject
之前,您应该检查 Application.Current.HasElevatedPermissions
和 AutomationFactory.IsAvailable
请注意,来自 http://localhost and http://127.0.0.1 的提升权限测试不是可靠的测试,因为 Silverlight 运行time 对这两个 URL 进行了例外处理。而是使用 file://
.
疑难解答
使用 ProcMon 验证是否正在读取 AllowElevatedTrustAppsInBrowser
注册表项
将调试器附加到 Silverlight(参见 screenshots)
MSIE 保护模式设置也会对 Silverlight 应用程序是否可以 运行 提升权限产生不利影响。尝试 运行 种不同的保护模式设置。
我们正在尝试允许用户使用 Silverlight XAP 运行 在浏览器中以高信任度从远程服务器扫描文档,但出现以下错误:
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 都 return 正确。
我可以成功创建不安全 ActiveX 控件的实例,例如Scripting.FileSystemObject
:
Dim fso = AutomationFactory.CreateObject("Scripting.FileSystemObject")
当 运行 来自远程服务器上的生产环境时,代码失败。当 运行 从本地主机的 ASP.NET 开发服务器时,代码成功,调用 CommonDialog.ShowAcquireImage()
.
我该如何解决这个问题? (是否有关于 WIA 的特定内容阻止以这种方式使用它?)我可以采取哪些步骤来尝试调试它?
更新
当我尝试打开生成的 Silverlight 测试页面(通过 file
协议)时,我遇到了同样的错误。
更新 2
进程监视器显示正在成功查询 AllowLaunchOfElevatedTrustApps
和 AllowElevatedTrustAppsInBrowser
键。
更新 3
关闭保护模式后,代码可以正常工作。
MSDN reference 声明要在浏览器中启用 COM Interop,您必须
设置注册表项
HKEY_LOCAL_MACHINE\Software\Microsoft\Silverlight\
(或在 x64 上HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Silverlight\
)AllowElevatedTrustAppsInBrowserDWORD
0x0000001
检查你的组策略没有禁用
AllowInstallOfElevatedTrustApps
和AllowLaunchOfElevatedTrustApps
签署 .xap
将证书安装到受信任的应用程序商店(参见 screenshots 说明)
此外,您必须
配置为浏览器外应用程序(即使您没有运行浏览器外)
在调用
ComAutomationFactory.CreateObject
之前,您应该检查Application.Current.HasElevatedPermissions
和AutomationFactory.IsAvailable
请注意,来自 http://localhost and http://127.0.0.1 的提升权限测试不是可靠的测试,因为 Silverlight 运行time 对这两个 URL 进行了例外处理。而是使用
file://
.
疑难解答
使用 ProcMon 验证是否正在读取
AllowElevatedTrustAppsInBrowser
注册表项将调试器附加到 Silverlight(参见 screenshots)
MSIE 保护模式设置也会对 Silverlight 应用程序是否可以 运行 提升权限产生不利影响。尝试 运行 种不同的保护模式设置。