I added a web reference to my project. The reference is clearly visible within my solutio开发者_开发知识库n. I have been able to instantiate all classes within the Reference.cs file but one. When I opened the Reference.cs file the class was not there. There is documentation of the existence of that class, but the class does not exist within my Reference file. I am using .Net 2005/2008. Could there be something wrong within .Net, If so are their any other ways around this?
If you're getting the error Source file 'C:\TFS\Project\Web References\WebService\Reference.cs' could not be opened ('Unspecified error ')
In Solution Explorer, Right click on the Web Service and select Update Web Reference.
Have you correctly decorated the class with a [DataContract]
attribute before generating the proxy? Does that class even exist in the webservice you targeted (you haven't generated a proxy against an old version of the service)?
I also had the same problem. I removed the service reference and added the service reference again, did a rebuild and voila, it started working again.
Another idea that catches me occasionally.
If your server-side DataContract class is named the same as a class you're using local to the client of the web service, Visual Studio re-uses types by default. Right-click on the Service Reference, Click on Configure and turn off Type re-use. No need to regenerate the reference, it should auto re-configure. If your class "appears", you might want to separate your naming.
精彩评论