相关疑难解决方法(0)

从.NET Windows服务调用Shell32.dll

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

库中失败的代码:

Shell32.Shell shell = new Shell();

错误:

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

我阅读了我的公寓线程,COM Interops,动态,PIA等等,但是我找到的解决方案没有解决问题.它必须是来自另一个无法看到Interop的线程的调用.请帮忙 :)

.net c# com multithreading shell32

10
推荐指数
2
解决办法
7030
查看次数

How to translate CreateObject("Wscript.shell") into C#

How could i translate this in c#?

Set WshShell = WScript.CreateObject( "WScript.Shell" )
Run Code Online (Sandbox Code Playgroud)

Thx. At what is this used? And also what is the library i have to include in c# in order to work?

c#

5
推荐指数
1
解决办法
1万
查看次数

使用C#从文件中获取MetaData信息

我试图使用Shell从文件中获取元数据.我正在使用MVC5和Windows 8操作系统.这是下面的代码.

public JsonResult Ind(string file)
{
    List<string> arrHeaders = new List<string>();
    string filename = Path.GetFileName(file);
    Shell shell = new ShellClass();
    Folder rFolder = shell.NameSpace(file);
    FolderItem rFiles = rFolder.ParseName(filename);
    for (int i = 0; i < short.MaxValue; i++)
    {
         string value = rFolder.GetDetailsOf(rFiles, i).Trim();
         arrHeaders.Add(value);
    }
    return Json(arrHeaders, JsonRequestBehavior.AllowGet);
 }
Run Code Online (Sandbox Code Playgroud)

当我尝试运行上面的代码时,我收到错误无法将"Shell32.ShellClass"类型的COM对象强制转换为接口类型"Shell32.IShellDispatch6".此操作失败,因为对IID为"{286E6F1B-7113-4355-9562-96B7E9D64C54}"的接口的COM组件的QueryInterface调用由于以下错误而失败:不支持此类接口(HRESULT异常:0x80004002(E_NOINTERFACE)) .

还有其他更好的解决方案来读取不同文件格式的元数据吗?请给我一些建议.我会感激你的.

谢谢

c#-4.0

3
推荐指数
1
解决办法
2673
查看次数

标签 统计

c# ×2

.net ×1

c#-4.0 ×1

com ×1

multithreading ×1

shell32 ×1