Then in my website I add a service reference(MyServiceRefernce) using the above URL. The WCF exposes objects which is used by the client.
In my pages I import the namespace "using MyServiceRefernce" and call the methods on the proxy which returns the object.
For example
MyServiceRefernce.ServiceClient
client = new
MyServiceRefernce.ServiceClient();
Contact
c = client.GetContact(contactId);
When I build my application and run from VS 2010 , everything runs fine. But when I run from IIS i get the following compilation error.
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'MyServiceReference' could not be found (are you missing a using directive or an assembly reference?)
The website uses forms-based authentication .
Please help me fix this error. I am in urgent
need.
Looks like some kind of misspelling somewhere in your code - the error message says "MyServiceReference" and your code says "MyServiceRefernce" - note the missing e. Thanks.
Have you tried to regenerate the service reference? You can also click the generated service reference, then click Show All files and then go to Reference.cs to see the exact namespace and class names you need to use to instantiate the proxy. I am guessing
you refreshed the service reference which caused some changes. If it still doesn't work - send me your client code with generated service reference at
piyush.joshi@microsoft.com and I'll take a look. Thanks.
This is what I noticed. My project is a website project. When I deploy under the default website , i get the compilation error that it is not able to find the WCF Namespace.
But when i browse the website using the machine name(http://servername/appname/userlogin.aspx) it directs me to the login page. I get authenticated and redirected to the default page. The menu links does not work any more.
I do not get any error .
sumu456
Member
35 Points
12 Posts
How to consume a WCF service hosted in IIS 7.0
Dec 08, 2011 09:00 PM|LINK
I've created a WCF project and hosted successfully in IIS 7.0 . When I browse to my service using the url
http://localhost:8000/MyService/Service.svc the form is displayed.
Then in my website I add a service reference(MyServiceRefernce) using the above URL. The WCF exposes objects which is used by the client.
In my pages I import the namespace "using MyServiceRefernce" and call the methods on the proxy which returns the object.
For example
MyServiceRefernce.ServiceClient client = new MyServiceRefernce.ServiceClient();
Contact c = client.GetContact(contactId);
When I build my application and run from VS 2010 , everything runs fine. But when I run from IIS i get the following compilation error.
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'MyServiceReference' could not be found (are you missing a using directive or an assembly reference?)
The website uses forms-based authentication .
Please help me fix this error. I am in urgent need.
Thanks
PiyushJo
Member
64 Points
17 Posts
Re: How to consume a WCF service hosted in IIS 7.0
Dec 08, 2011 09:38 PM|LINK
Looks like some kind of misspelling somewhere in your code - the error message says "MyServiceReference" and your code says "MyServiceRefernce" - note the missing e. Thanks.
sumu456
Member
35 Points
12 Posts
Re: How to consume a WCF service hosted in IIS 7.0
Dec 08, 2011 11:18 PM|LINK
That was a typo.
sumu456
Member
35 Points
12 Posts
Re: How to consume a WCF service hosted in IIS 7.0
Dec 09, 2011 01:07 AM|LINK
Experts please help me to resolved this error.
The service reference is "MyServiceRefernce", then why do i get the compilation error.
PiyushJo
Member
64 Points
17 Posts
Re: How to consume a WCF service hosted in IIS 7.0
Dec 09, 2011 04:47 AM|LINK
Have you tried to regenerate the service reference? You can also click the generated service reference, then click Show All files and then go to Reference.cs to see the exact namespace and class names you need to use to instantiate the proxy. I am guessing you refreshed the service reference which caused some changes. If it still doesn't work - send me your client code with generated service reference at piyush.joshi@microsoft.com and I'll take a look. Thanks.
sumu456
Member
35 Points
12 Posts
Re: How to consume a WCF service hosted in IIS 7.0
Dec 09, 2011 02:58 PM|LINK
This is what I noticed. My project is a website project. When I deploy under the default website , i get the compilation error that it is not able to find the WCF Namespace.
But when I add the website under the Sites folder and give a new port number, the project works fine.http://localhost:8050/UserLogin.aspx.
How do i get it working under the default web site. I do not want to use the port number in the URL.
Thanks
sumu456
Member
35 Points
12 Posts
Re: How to consume a WCF service hosted in IIS 7.0
Dec 09, 2011 03:14 PM|LINK
The issue is similar to the one discussed in this thread
http://social.msdn.microsoft.com/Forums/ar/wcf/thread/6c574eed-3b7d-43b8-9ed6-93b5c12d46f5
sumu456
Member
35 Points
12 Posts
Re: How to consume a WCF service hosted in IIS 7.0
Dec 09, 2011 09:16 PM|LINK
I finally managed to get the website up and running. But still it does not work correctly.
Everything works fine when browse through localhost (http://localhost/appname/userlogin.aspx)
But when i browse the website using the machine name(http://servername/appname/userlogin.aspx) it directs me to the login page. I get authenticated and redirected to the default page. The menu links does not work any more. I do not get any error .
Please help me troubleshoot the problem.
Thanks much.
sujeet_kumar
Member
198 Points
55 Posts
Re: How to consume a WCF service hosted in IIS 7.0
Dec 10, 2011 03:26 AM|LINK
hi
see this link , it is help full.
http://wcftutorial.net/WCF-Hosting.aspx
Software Developer
MCTS,MCPD