I am having trouble linking to a secondary class in my project - I have attached 2 images which describe the problem best..
Pleas any a开发者_StackOverflow中文版dvice - I thank you in advance.
This error was two things - thank you everybody for your help. 1) add namespace to DB file
namespace C_Classes
{ using System; ...
public class DB
2) Change Target Framework in the Project Properties and change it to ".Net Framework 4" from "...Client Profile"
I'm assuming you've added a Project reference to the C_Classes project?
Otherwise I've seen these types of issues when the project is set to target ".Net Framework 4 Client Profile" (which it sometimes sets as the default).
Check your Target Framework in the Project Properties and change it to ".Net Framework 4".
Your snippet of (presumably) DB.cs doesn't show a namespace declaration - so the DB
class is just in the global namespace. If you want it in the C_Classes namespace you'll need:
namespace C_Classes
{
public class DB
{
// etc
}
}
Unlike VB, a C# class doesn't end up in a namespace without a namespace declaration appearing in the source code.
I couldn't see a namespace enclosing your DB
class.
Enclose your DB
class as shown below:
namespace C_Classes
{
using System;
...
public class DB
{
}
}
Does the second project have a reference to the first one? That isn't made clear in the images provided. Expand the "References" folder in the second project and see if there's a reference to the first project there. If there isn't, just right-click on the "References" folder and add a Project Reference to it.
The second thing I notice is that there's no explicit namespace in the DB
file. I'm not 100% sure if there's an implicit one when it's compiled in an assembly, but I wouldn't count on it. Try wrapping that class in an explicit C_Classes
namespace and see if that helps.
精彩评论