简体   繁体   English

C#Windows API代码包

[英]C# Windows API Code Pack

I'm using Visual Studio 2010 Express for C# and am having trouble installing the code pack. 我正在使用Visual Studio 2010 Express for C#,但在安装代码包时遇到问题。 I downloaded the source from MSDN and don't know what to do with it? 我从MSDN下载了源代码,不知道该怎么办? I opened the WindowsAPICodePack.sln and attempted to build the project and got: 我打开了WindowsAPICodePack.sln并尝试构建项目并得到:

Error 16 The type or namespace name 'ContentPropertyAttribute' could not be found (are you missing a using directive or an assembly reference?) C:\\Users\\Joe\\Downloads\\WindowsAPICodePack\\Shell\\CommonFileDialogs\\CommonFileDialogRadioButtonList.cs 13 6 Shell 错误16找不到类型或命名空间名称'ContentPropertyAttribute'(您是否缺少using指令或程序集引用?)C:\\ Users \\ Joe \\ Downloads \\ WindowsAPICodePack \\ Shell \\ CommonFileDialogs \\ CommonFileDialogRadioButtonList.cs 13 6 Shell

and

Error 13 The type name 'IComponentConnector' could not be found in the namespace 'System.Windows.Markup'. 错误13在名称空间“System.Windows.Markup”中找不到类型名称“IComponentConnector”。 This type has been forwarded to assembly 'System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Consider adding a reference to that assembly. 此类型已转发到程序集'System.Xaml,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'考虑添加对该程序集的引用。 C:\\Users\\Joe\\Downloads\\WindowsAPICodePack\\Shell\\obj\\Debug\\Controls\\CommandLinkWPF.g.cs 42 99 Shell C:\\ Users \\ Joe \\ Downloads \\ WindowsAPICodePack \\ Shell \\ obj \\ Debug \\ Controls \\ CommandLinkWPF.g.cs 42 99 Shell

each about 5-6 times each. 每个约5-6次。

I attempted to build the samples also but got similar errors. 我也试图建立样本,但也有类似的错误。

How do I install the code into Visual Studio? 如何将代码安装到Visual Studio中?

How do I fix the errors? 如何修复错误?

How do I include the code into my projects? 如何将代码包含到我的项目中?

Can I make the Library usable in my projects with just a "using" command? 我可以只使用“using”命令使库在我的项目中可用吗?

System.Xaml.dll的引用添加到您的项目中。

I've just downloaded version 1.0.1, opened it up in Visual Studio 2010 Professional and built it with no problems at all. 我刚刚下载了1.0.1版本,在Visual Studio 2010 Professional中打开它并构建它没有任何问题。

Check which version of .NET your projects are now targeting. 检查您的项目现在定位的.NET版本。 It's possible that the Express edition automatically "upgrades" projects to target .NET 4, whereas mine have been left targeting .NET 3.5. Express版本可能会自动“升级”项目以定位.NET 4,而我的目标仍然是针对.NET 3.5。

Another thing to check - do you have .NET 3.5 installed? 另一件需要检查的事情 - 你是否安装了.NET 3.5? I'd expect so, but it's worth checking. 我希望如此,但值得检查。

When you've built the projects, you need to do two things to use them: 在构建项目时,需要做两件事来使用它们:

  • Add a reference to the built assembly (eg Microsoft.WindowsAPICodePack.dll) 添加对构建的程序集的引用(例如Microsoft.WindowsAPICodePack.dll)
  • Add a using directive to the appropriate namespace. using指令添加到适当的命名空间。 (This is actually optional, but otherwise you'll have to use the fully-qualified name for any type in the library, which isn't generally what you want.) (这实际上是可选的,但是否则你必须使用库中任何类型的完全限定名称,这通常不是你想要的。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM