In one namespace (Ventosa.Graphics) I have a public class named Model
namespace Ventosa.Graphics
{
public class Model : GraphicsResource
{
public Model(...)
{
...
}
...
}
}
Then in another project I try to access this class
Model player = new Model(...);
But this line creates an error. C# recognizes that Model exists, but claims that it isn’t accessible due to it’s protection level. Shouldn’t making it public mean it’s accessible from everywhere?
And yes, the base class GraphicsResource is public.
This happens in a few other places in my project too, all with classes that are derived.
EDIT:
The exact error message is (in German):
Der Zugriff auf “Ventosa.Graphics.Model” ist aufgrund der Sicherheitsebene nicht möglich. Translated to English, it says: “Ventosa.Graphics.Model” is inaccessible due to its protection level.
You describe something that clearly should not be. I’d suggest that you try to reproduce the problem in the simplest way possible. You probably won’t be able to. Then add to your sample, making it more and more like your production code, until you trigger the problem.
Remove the reference to the superclass
GraphicResource. Make sure there’s only one constructor defined. Try to instantiate that class from the same namespace, using full namespace references (notusingstatements) and that single, explicit constructor. It’ll probably work.If it doesn’t work, step back a bit and define a new type entirely (
Ventosa.Graphics.ModelTestor something). Make sure that works.Now, add pieces back in. Inherit from
GraphicResource, try that. Remove the namespace qualifications; useusinginstead. Move the instantiation to a different namespace, then a different assembly.You’ve verified that the definition of the
GraphicResourceclass is public. What about any of its superclasses?