views:

727

answers:

7

Ok so I have an ASP.Net website project. The project resides on a server on the network, accessed by Visual Studio 2008 via a fileshare.

In the web site project I add a web reference to a webservice I have previously created.
I can consume this webservice via winforms apps without any problems.

But when I try to reference the Webservice in my code, no intellisense comes up, and the service name gets the red underline in Visual Studioand say s "The type or namespace name 'IMWebService' could not be found are you missing an assembly reference or a using directive?"

However, if I know the exact method signature of a method of the webservice, I can type it in, save it to the webserver, and it works just fine. For example:

bool test = Contractor.CheckLogin(email, password);

How do I get my Visual Studio to recognize the service just as the website is doing?

A: 

Check namespaces, there might be the problem. If you enter full name look for small red box under it.

If it doesn't work you may have broken Intellisense, because I use it everyday and it works.

Migol
If the namespace was a problem then it wouldn't compile either. And its not like intellisense breaks alltogether, it still works on other types/namespaces, it juse doesnt work for Webservices
Neil N
A: 

Put the following line at the top of your code file:

using Contrator;

If Visual Studio is not providing intellisense yet the code compiles when you use the fully-qualified name then you can be fairly confident that adding the namespace in a using statement will solve the problem.

If you do not have the namespace specified at the top of the file the IDE does not know how to resolve the type.

Andrew Hare
That's not true, Intellisense works fine without using "using" for a namespace. Intellisense follows all the same rules as the compiler with respect to searching for a class.
Rex M
Yes it does but the OP was typing just the class name when he received the error - if he uses the whole name then everything is fine.
Andrew Hare
Normally (outside of this case) Intellisense works fine without namespace declarations - try it. As long as the class can be resolved by the compiler, intellisense should pick it up as well.
Rex M
+1  A: 

I've encountered this problem, isolated only to classes created via "Web References". One solution was to clean out the bin and obj folders and restart Visual Studio. That didn't always work, so maybe it's not a "solution", but sometimes Intellisense picked up after that. I also tried opening up the auto-genned code for the web service and modifying it, then saving. That seemed to kickstart Intellisense into watching that file. Nothing else I did seemed to have an effect.

Rex M
Cleaning out the bin folder and rebuilding did the trick. +1 for now as I still have 7 days to pick and aswer and I might delve deeper into this.
Neil N
A: 

You could try pulling the auto generated code for the webservice client VS makes for you from the temp area and add it to your actual project

BPAndrew
A: 

Use a web application project instead of a website.

File -> New -> Project -> C# -> Web -> ASP.NET Web Application

This will solve your problem as well as other problems.

The Web Site project is old and doesn't work.

Jonathan Parker
same problem in either project type
Neil N
A: 

To help narrow the scope of the problem:

  • Have you checked to the code access policy from using VS projects over a UNC path?
  • Do you get any warnings about using opening untrusted code from a file share?
  • Do you get this same behavior if you run all your code locally?
MotoWilliams
A: 

once I've faced the same problem, I just right click on the refrence folder in project explorer in visual studio, selecting the Refresh, and then after 2 or 3 minutes, intelisense comes up and works fine.. I think it needs some time to download the schema and web service class information or something like that.

mohamadreza
ya tried this, it didnt work
Neil N