使用提升的权限启动 COM (.NET) 对象会引发 FileNotFoundException
我正在尝试通过 CoGetObject 方法启动 .NET 对象,如 COM Elevation 中所述MSDN 上的 Moniker 文章。我开始使用 Vista Bridge 代码,然后偶然发现了一个较旧的示例,其中显示了一些已连接的位 。此时,我试图弄清楚为什么在调用此方法时会抛出 FileNotFoundException:
var result = UnsafeNativeMethods.CoGetObject(monikerName, ref bindingOptions, interfaceId);
该异常仅在显示同意提示后抛出,这很奇怪。我正在 Windows 7 x64 机器上工作,如果这有帮助的话,并且已经发布了我的尖峰的完整来源 。
我在这里缺少什么可能导致抛出 FileNotFoundException ?
I am trying to launch a .NET object through the CoGetObject method as outlined in the COM Elevation Moniker article on MSDN. I started working with the Vista Bridge code and then stumbled across an older sample that shows some of the bits wired up. At this point I am trying to figure out why I am getting a FileNotFoundException thrown when the call goes through to this method:
var result = UnsafeNativeMethods.CoGetObject(monikerName, ref bindingOptions, interfaceId);
The exception only throws after the consent prompt is displayed which is strange. I am working on a Windows 7 x64 machine if that helps and have posted the full source of my spike.
What am I missing here that might cause a FileNotFoundException to be thrown?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否使用 /tlb 开关运行 RegAsm.exe 来导出并注册 COM 服务器的类型库?没有注册类型库可能会导致 FileNotFoundException。
Did you run RegAsm.exe with the /tlb switch to export and register a typelib for the COM server? Not having a registered typelib may result in a FileNotFoundException.
这不是直接的答案,但您可以使用 RunElevatedNet C# 示例项目来尝试在提升的项目中或不在提升的项目中启动 COM 服务器。调查在非提升模式下是否也发生相同的 FileNotFoundException 错误可能有助于调试您的问题。
This is not directly an answer, but you can probably use the RunElevatedNet C# sample project to try launching your COM server in either a elevated project or not. Investigating if the same FileNotFoundException error also occur in non-elevated mode might help debug your issue.