Compiler Error Message: CS0234 namespace not found - c#

I'm getting a compiler error with the Service Reference I've added to the .NET project. The second image show that the Service reference is defined at namespace Jwaala.Site.User.coopBetaServiceTokenProvider, yet I'm still getting a complier error, why?

Ideally there should be a service layer which will handle these WCF connections , that should be ideal/first step to fix.

Related

compile error "type or namespace name could not be found" but available through intellisense auto-complete in code?

I have a C# MVC app. I've added a NuGet package reference which has the following object:
MyCorp.Security.Framework.Components.User
I have a reference to this User object in my MVC app and the intellisense/auto-complete picks it up as well but when I rebuild the app I get a compile error:
"The type or namespace name 'MyCorp' could not be found"
I tried Clean/Rebuild but I still get the error. Any idea what the issue might be?

refactoring namespace in RESTFul WCF causes error at runtime

I create a "WCF Service Application" project.
I make the interface, then class, a [DataMember] decorated object, and Global.asax.cs Global class in the same namespace, parentns.mynamespage.
I run this in VStudio IIS Express and everything is great.
.
Then I realize I want to refactor the namespace to parentns.subnamespace.
That is the only change alone in Imyclass.cs (the object also exists in this file), myClass.cs, and Global.asax.cs recompile and F5-run again in VStudio Imyclass
Now I get:
"the remote server returned an error: (500) Internal Server Error"
Nothing is reported of interest in the Output window except a very generic
"Exception thrown: 'System.Net.WebException' in System.dll"
If I Ctrl-Z everything and rerun everything works again.
What else am I needing to refactor?
How do you troubleshoot this?
Thanks for you help
Sorry. Immediately after posting this question I had the thought to search-and-replace.
I found a reference in the primary global file 'Global.asax' pointing to the old namespace. Updated that and everything works fine.
Thanks.

WSDL ReportExecution proxy file does not compile due to ambiguity errors

I'm using ReportExecution proxy class in my program. When I try to compile it, I get 58 ambiguity errors in generated file. This is the sample error output:
Error 1 The namespace '<global namespace>' already contains a definition for 'LogonUserCompletedEventHandler'
Error 2 The namespace '<global namespace>' already contains a definition for 'LogoffCompletedEventHandler'
Error 4 Ambiguity between 'ServerInfoHeader.reportServerVersionNumberField' and 'ServerInfoHeader.reportServerVersionNumberField'
Error 5 Ambiguity between 'ServerInfoHeader.reportServerEditionField' and 'ServerInfoHeader.reportServerEditionField'
Error 6 Ambiguity between 'ServerInfoHeader.reportServerEditionField' and 'ServerInfoHeader.reportServerEditionField'
Should I change automatically generated file to fix that? Or maybe the error is somewhere else?
Thanks in advance.
EDIT:
I have dealt with most of the ambiguity errors, they were because I unnecessarily added web references instead of only using the proxy classes. Now, however, I still get 2 errors:
Error 1 The namespace '<global namespace>' already contains a definition for 'LogonUserCompletedEventHandler'
Error 2 The namespace '<global namespace>' already contains a definition for 'LogoffCompletedEventHandler'
I also received the same '<global namespace>' error because I had included the proxy code generated by wsdl.exe in the visual studio project, but also had left the actual source WSDL file in the project's directory structure.
ASP.NET appears to auto-compile this WSDL file into another copy of proxy code the site when it's loaded.
This doesn't give a compile time error in VS, but will cause the site to fail with error's 1 and 2 described in the question.
Removing the WSDL file from the directory structure corrects the problem.
Well, it seems that wsdl proxies have to be generated with distinct namespaces if you use more than one. Adding /namespace parameter solved the problem.

The type 'StringPro.IMyString' is defined in an assembly that is not referenced

I receive this error when trying to run the client.
The type 'StringPro.IMyString' is defined in an assembly that is not referenced.
This error comes from, StringProClient from file Program.cs and underlines in blue the following first line of code:
StringProProxy.StringProProxy proxy = new StringProProxy.StringProProxy();
The solution has 4 projects inside:
StringPro - Class Library that contains the service's interface(IMyString.cs) and the implementation class(MyString.cs)
StringProHost - Console Application that has Program.cs inside which defines Uri, ServiceHost, Endpoint, ServiceMetadataBehaviour, HttpGetEnabled, host.Description.Behaviours, calls host.Open() and displays in console information about when the service was started
StringProProxy - I believe it's a Class Library project since it has only StringProProxy.cs which defines the service's proxy
StringProClient - Console Application which instantiates the service's proxy inside, call the service's functions and displays results.
EDIT: The service host launches fine. It's the client that won't build and run because of the mentioned error.
If a project is using a type that was declared in other assembly, this assembly must be referenced - this is basically what your error is telling you.
In your case, I'm guessing that StringProClient is referecing StringProProxy, but it is also using types declared in StringPro project (to be exact: IMyString interface/class), without referencing it. You should make sure, that StringProClient references both, StringProProxy and StringPro.
Such problem mostly arises with the issues like namespace only. Kindly check your references as well as namespaces again.

Why do I get this error in a WebServices project?

I have a ClickOnce app that accesses a bunch of web services. On the client, I have one project that wraps all the web services.
In the Properties for that project, if Build/Generate Serialization Assembly is Auto (which is the default), then everything works fine. I set the option to On, it compiles fine, then during runtime I get this error:
Line 786: [WebMethod]
Line 787: public CC.DTO.AdvertiserAssignmentRevenueDTO[] SearchAdvertiserAssignmentRevenue(byte[] AdvAssgnRevenueSearchFilter)
Line 788: {
Line 789: try
The Detailed Compiler Output is basically "CS0234: The type or namespace name 'DTO' does not exist in the namespace 'CC' (are you missing an assembly reference?)"
Why is this happening?
Just FYI, this is a .NET 2.0 project running in VS2008.
I had a very similar error message with the same symptoms. For me it would even run locally but not on a different server. It turned out I was missing a data contract declaration on one of my methods.
[DataContract (Namespace = ...)]
Double check your methods on the service and client to ensure they have all the needed attributes and declarations.

Categories