<small id='fPuyu'></small><noframes id='fPuyu'>

<tfoot id='fPuyu'></tfoot>
  • <legend id='fPuyu'><style id='fPuyu'><dir id='fPuyu'><q id='fPuyu'></q></dir></style></legend>
      <bdo id='fPuyu'></bdo><ul id='fPuyu'></ul>
    <i id='fPuyu'><tr id='fPuyu'><dt id='fPuyu'><q id='fPuyu'><span id='fPuyu'><b id='fPuyu'><form id='fPuyu'><ins id='fPuyu'></ins><ul id='fPuyu'></ul><sub id='fPuyu'></sub></form><legend id='fPuyu'></legend><bdo id='fPuyu'><pre id='fPuyu'><center id='fPuyu'></center></pre></bdo></b><th id='fPuyu'></th></span></q></dt></tr></i><div id='fPuyu'><tfoot id='fPuyu'></tfoot><dl id='fPuyu'><fieldset id='fPuyu'></fieldset></dl></div>
      1. 从 .NET Windows 服务调用 Shell32.dll

        Calling Shell32.dll from .NET Windows Service(从 .NET Windows 服务调用 Shell32.dll)

          <i id='Sqvyg'><tr id='Sqvyg'><dt id='Sqvyg'><q id='Sqvyg'><span id='Sqvyg'><b id='Sqvyg'><form id='Sqvyg'><ins id='Sqvyg'></ins><ul id='Sqvyg'></ul><sub id='Sqvyg'></sub></form><legend id='Sqvyg'></legend><bdo id='Sqvyg'><pre id='Sqvyg'><center id='Sqvyg'></center></pre></bdo></b><th id='Sqvyg'></th></span></q></dt></tr></i><div id='Sqvyg'><tfoot id='Sqvyg'></tfoot><dl id='Sqvyg'><fieldset id='Sqvyg'></fieldset></dl></div>

              • <bdo id='Sqvyg'></bdo><ul id='Sqvyg'></ul>

                <small id='Sqvyg'></small><noframes id='Sqvyg'>

                    <tbody id='Sqvyg'></tbody>
                1. <legend id='Sqvyg'><style id='Sqvyg'><dir id='Sqvyg'><q id='Sqvyg'></q></dir></style></legend>
                  <tfoot id='Sqvyg'></tfoot>
                  本文介绍了从 .NET Windows 服务调用 Shell32.dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个 .NET 4.0 库,它使用 Shell32 和 Folder.GetDetailsOf() 从 WTV 文件中获取元数据.我已经成功地将它与控制台和 Windows 窗体应用程序一起使用,没有问题.但由于某种原因,当从 .NET 4.0 Windows 服务调用组件时,调用启动 Shell 类会导致 COM 错误.

                  I have a .NET 4.0 library that uses Shell32 and Folder.GetDetailsOf() to get metadata from WTV files. I have used it successfully with Console and Windows Forms apps without issue. But for some reason, when calling the component from a .NET 4.0 Windows Service, the call to initiate the Shell class causes a COM error.

                  库内失败的代码:

                  Shell32.Shell shell = new Shell();

                  Shell32.Shell shell = new Shell();

                  错误:

                  无法将System.__ComObject"类型的 COM 对象转换为接口类型Shell32.Shell".此操作失败,因为 IID 为{286E6F1B-7113-4355-9562-96B7E9D64C54}"的接口的 COM 组件上的 QueryInterface 调用失败,原因是以下错误:不支持此类接口(HRESULT 异常:0x80004002 (E_NOINTERFACE)).

                  Unable to cast COM object of type 'System.__ComObject' to interface type 'Shell32.Shell'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{286E6F1B-7113-4355-9562-96B7E9D64C54}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

                  我阅读了我的 Apartment Threading、COM Interops、Dynamic、PIA's 等,等等 :) 但我找到的解决方案组合都没有解决这个问题.它必须是来自另一个看不到互操作的线程的调用.请帮忙:)

                  I read my fill of Apartment Threading, COM Interops, Dynamic, PIA's, etc, etc, etc :) But no combination of solutions I've found has solved the problem. It must be a calling from another thread that can't see the Interop. Help, please :)

                  推荐答案

                  我最近在使用命令行应用程序(控制台)时遇到了同样的问题.事实证明,需要使用 [STAThread] 属性来注释程序的 Main() 方法.还需要注意的是,如果入口点使用 [MTAThread] 进行注释,它会以完全相同的方式失败.希望对你有帮助.

                  I had the same problem just recently with a command line application (console). Turns out, it was required to annotate the program's Main() method with the [STAThread] attribute. It has also been noted that it fails miserably in the exact same way if the entry point is annotated with [MTAThread] instead. I hope it helps.

                  这篇关于从 .NET Windows 服务调用 Shell32.dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Performance overhead of using attributes in .NET(在 .NET 中使用属性的性能开销)
                  Accessing attribute info from DTE(从 DTE 访问属性信息)
                  c# Hide a property in datagridview with datasource(c#使用数据源隐藏datagridview中的属性)
                  Extract Display name and description Attribute from within a HTML helper(从 HTML 帮助器中提取显示名称和描述属性)
                  How can I force the PropertyGrid to show a custom dialog for a specific property?(如何强制 PropertyGrid 显示特定属性的自定义对话框?)
                  Associate attribute with code generated property in .net(将属性与 .net 中的代码生成属性相关联)

                      <bdo id='gkwUy'></bdo><ul id='gkwUy'></ul>
                      1. <small id='gkwUy'></small><noframes id='gkwUy'>

                          <i id='gkwUy'><tr id='gkwUy'><dt id='gkwUy'><q id='gkwUy'><span id='gkwUy'><b id='gkwUy'><form id='gkwUy'><ins id='gkwUy'></ins><ul id='gkwUy'></ul><sub id='gkwUy'></sub></form><legend id='gkwUy'></legend><bdo id='gkwUy'><pre id='gkwUy'><center id='gkwUy'></center></pre></bdo></b><th id='gkwUy'></th></span></q></dt></tr></i><div id='gkwUy'><tfoot id='gkwUy'></tfoot><dl id='gkwUy'><fieldset id='gkwUy'></fieldset></dl></div>
                          <legend id='gkwUy'><style id='gkwUy'><dir id='gkwUy'><q id='gkwUy'></q></dir></style></legend>

                          <tfoot id='gkwUy'></tfoot>
                              <tbody id='gkwUy'></tbody>