The type or namespace name 'xxx could not be found

RadhaKrishnaKiJaya
RadhaKrishnaKiJaya used Ask the Experts™
on
Hello Experts,
I am trying to create a Windows Service project, which uploads data from an API.  In one class, I am trying to access an external class name ManageData, with in the same project.  But, getting the below error message.  Please see the attached picture.  Please let me know how to fix it.  Thank you in advance.

Error      CS0246:      The type or namespace name 'ManageData' could not be found (are you missing a using directive or an assembly reference?)

Thank you!
Service.png
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Fernando SotoRetired
Distinguished Expert 2017

Commented:
Hi RadhaKrishnaKiJaya;

The class in the posted image is declared as private. It must be changed so that it can be Accessed from outside that class. See below
From Microsoft documentation Access Modifiers (C# Programming Guide)
All types and type members have an accessibility level, which controls whether they can be used from other code in your assembly or other assemblies. You can use the following access modifiers to specify the accessibility of a type or member when you declare it:

public
The type or member can be accessed by any other code in the same assembly or another assembly that references it.

private
The type or member can be accessed only by code in the same class or struct.

protected
The type or member can be accessed only by code in the same class, or in a class that is derived from that class.

internal
The type or member can be accessed by any code in the same assembly, but not from another assembly.

protected internal
The type or member can be accessed by any code in the assembly in which it is declared, or from within a derived class in another assembly.

private protected
The type or member can be accessed only within its declaring assembly, by code in the same class or in a type that is derived from that class.

Author

Commented:
Hello Fernando,
Thank you for your help.  I tried all other declaration types.  None of them works.  Here I am trying to access ManageData, which is external.  I am not sure how the declaration type matters here.  Still I tried all in your list.

Thank you!
Commented:
What is the namespace that your ManagedData class resides in? You have to add a using statement for that namespace.  You can try to have Visual Studio auto detect the namespace by left mouse clicking on the ManagedData type and then pressing the key combination Ctrl + <period>.Capture.PNG-saige-

Author

Commented:
Thank you Saige.  That is was missing.  It worked now.  Thank you again.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial