wpf ShellFile 错误:缺少程序集引用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24129691/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 11:52:54  来源:igfitidea点击:

ShellFile Error: missing assembly reference?

c#wpfwindows-api-code-pack

提问by user2368363

I cannot find the namespace for ShellFile.

我找不到ShellFile.

I have added using System.Windows.Shelland also tried loading the Windows7APICodePack through the package manager console:

我已经添加using System.Windows.Shell并尝试通过包管理器控制台加载 Windows7APICodePack:

PM> install-Package Windows7APICodePack

Installing 'Windows7APICodePack 1.0.0.0'.

You are downloading Windows7APICodePack from Microsoft, the license agreement to which is available at http://code.msdn.microsoft.com/WindowsAPICodePack/Project/License.aspx. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.

Successfully installed 'Windows7APICodePack 1.0.0.0'.

Adding 'Windows7APICodePack 1.0.0.0' to CADBuilderGUI.

Successfully added 'Windows7APICodePack 1.0.0.0' to CADBuilderGUI.

PM> install-Package Windows7APICodePack

安装“Windows7APICodePack 1.0.0.0”。

您正在从 Microsoft 下载 Windows7APICodePack,其许可协议可从http://code.msdn.microsoft.com/WindowsAPICodePack/Project/License.aspx 获得。检查包中是否有其他依赖项,这些依赖项可能带有他们自己的许可协议。您对包和依赖项的使用构成您接受他们的许可协议。如果您不接受许可协议,请从您的设备中删除相关组件。

成功安装“Windows7APICodePack 1.0.0.0”。

向 CADBuilderGUI 添加“Windows7APICodePack 1.0.0.0”。

已成功将“Windows7APICodePack 1.0.0.0”添加到 CADBuilderGUI。

I just tried installing the later version 1.1.0.0 with:

我只是尝试使用以下方法安装更高版本的 1.1.0.0:

PM> Install-Package Windows7APICodePack-Shell

but still no luck.

但仍然没有运气。

I am simply trying to get a thumbnail image of a file with:

我只是想通过以下方式获取文件的缩略图:

ShellFile shellFile = ShellFile.FromFilePath(files[0]);
Bitmap shellThumb = shellFile.Thumbnail.ExtraLargeBitmap;

But it doesn't know what ShellFileis.

但它不知道是什么ShellFile

Any suggestions?

有什么建议?



This is not a duplicate of thisbecause PresentationFramework.dll is added by reference and I am building in Framework 4.0.

这不是这个副本因为 PresentationFramework.dll 是通过引用添加的,我在 Framework 4.0 中构建。

回答by cpmars

PM> Install-Package WindowsAPICodePack-Core

PM> Install-Package WindowsAPICodePack-Core

PM> Install-Package WindowsAPICodePack-Shell

PM> Install-Package WindowsAPICodePack-Shell

Install these two and it will work.

安装这两个,它会工作。

回答by user2368363

It turns out that after downloading the latest packages as stated from above, you have to browse to the .dll package locations and add both by reference, then add the package namespaces:

事实证明,在下载上述最新包后,您必须浏览到 .dll 包位置并通过引用添加两者,然后添加包命名空间:

using Microsoft.WindowsAPICodePack.Shell;
using Microsoft.WindowsAPICodePack;