I have following working code (for consuming a WCF service).
SecurityRoleWebService is a namespace.
SecurityWebserviceManagerImplClient is a class corresponding to a WCF service.
getSecurityRoles() is a method corresponding to service operation.
When I add the namespace as
using SecurityRoleWebService
I am getting the following error:
Error: The type or namespace name ‘SecurityRoleWebService’ could not be found (are you missing a using directive or an assembly reference?)
Why is it so? How to overcome this?
SecurityRoleWebService.SecurityWebserviceManagerImplClient proxySecurityRole = new SecurityRoleWebService.SecurityWebserviceManagerImplClient();
SecurityRoleWebService.SecurityRole[] roles = proxySecurityRole.getSecurityRoles(userID);
string roleName = roles[0].roleName;
Use the full qualified namespace of the class. When you a using a ServiceReference, the generated namespace is
[default namespace of your project].[name of the service reference]. You have to use this full qualified namespace in a using.When you prefix a class like you did with
new SecurityRoleWebService.SecurityWebserviceManagerImplClient();you can use a relative namespace (relative to the namespace the codeblock is in).When you write a using, this you are not in a codeblock that has a namespace, so there is no namespace to relate to. You have to use the full qualified namespace.