简体   繁体   中英

How to fix C# error “The type or namespace name '[x]' could not be found (are you missing a using directive or an assembly reference?)”

I would like to use the open source code from here - Roger Lipscombe's .NET wizard form classes.

Unfortunately for me my target is a Windows Mobile 6.5 device and not a Win7/VS 2010 project. So since I could not use the projects as is I decided to create the two dependency projects by hand for the mobile device in VS2008.

Things seemed to go well until I tried to compile.

I am not sure now why i get the following error:

Error 1 The type or namespace name 'CategoryAttribute' could not be found (are you missing a using directive or an assembly reference?) C:\\Development\\SmartDeviceProject1\\Wizard.Controls\\EtchedLine.cs 50

The line of code is:

[Category("Appearance")]

I think the open source project is using .NET 2 and the mobile project is 3.5.

I am a C++ developer trying to make a mobile app with a wizard UI.

Can someone perhaps point out what I may be missing and what this error means and how to fix it?

EDIT

Thanks all who answered.
Commenting those decorators out fixed the problem (though I have a lot of issues apparently with things that are NOT supported in the compact framework. Oh well - it wa worth a shot)

The CategoryAttribute is used when the control is loaded in visualstudio ie when editing the form and how to find the associated property in the property grid. You could probbaly just comment it out with no ill effects. The associated property will just appear somewhere else in the grid.

The category attribute can just be commented out without any negative consequences.

If you have that error with other code, ask again and we'll try to help you find an equivalent for .NETCF or a workaround.

It appears that [Category("Appearance")] adds a new Design-time option in the

Designer under the "Appearance" category in this instance.

Note that in the examples that I've found use [CategoryAttribute("Appearance")]

The property is then followed by a variable, as the sample you've provided would allow you to set a color for Light and Dark of an etched line.

Here is a very detailed article on the subject, however the line of code [Category("Appearance")] may not be required as it's for the Designer only.

http://msdn.microsoft.com/en-us/magazine/cc164159.aspx#S8 - Figure 11

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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