views:

69

answers:

2

I'm using Visual Studio 2010 Express for C# and am having trouble installing the code pack. I downloaded the source from MSDN and don't know what to do with it? I opened the WindowsAPICodePack.sln and attempted to build the project and got:

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

and

Error 13 The type name 'IComponentConnector' could not be found in the namespace 'System.Windows.Markup'. 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. C:\Users\Joe\Downloads\WindowsAPICodePack\Shell\obj\Debug\Controls\CommandLinkWPF.g.cs 42 99 Shell

each about 5-6 times each.

I attempted to build the samples also but got similar errors.

How do I install the code into 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?

+3  A: 

Add a reference to System.Xaml.dll to your project.

Robert Harvey
That works perfectly! How do I include the API code into one of my projects? Just use the same Xmal reference?
Nat
The second error message suggests that the `ComponentConnector` type and the `ContentPropertyAttribute` type now reside in the `System.Xaml` namespace that is in the new `System.Xaml.dll` that comes with the code pack.
Robert Harvey
So yes, once the code pack is installed, you can just add the new reference to your own projects.
Robert Harvey
+4  A: 

I've just downloaded version 1.0.1, opened it up in Visual Studio 2010 Professional and built it with no problems at all.

Check which version of .NET your projects are now targeting. It's possible that the Express edition automatically "upgrades" projects to target .NET 4, whereas mine have been left targeting .NET 3.5.

Another thing to check - do you have .NET 3.5 installed? 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 (e.g. Microsoft.WindowsAPICodePack.dll)
  • Add a using directive to the appropriate namespace. (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.)
Jon Skeet
Where does the correct Microsoft.WindowsAPICodePack.dll go? I was looking through the documentation and realized that I don't have all the namespaces I should. I looked through my project folder and have 3-4 different Microsoft.WindowsAPICodePack.dll in different sub-folders of the WindowsAPICodePack folder
Nat
@Nat: They should be the same - basically some of the projects reference it themselves, so they'll have their own copies. For the "original" one, just look under Core/bin/debug (or Core/bin/release)
Jon Skeet