How to debug a WCF Service Application? - asp.net

Newbie question. In vs2010 (.net 4.0), I used the WCF Service Application template to create a Web Application. This was then published using Web Deploy to IIS 7 residing on the same box as my client application.
How can the WCF Service Application be debugged?
I have tried this:
Set a breakpoint in the Service1.svc.cs code.
Recompile all with a debug configuration. Build target is to bin\
Publish the WCF Service Application project to the local IIS7 website.
Start the client application which calls the IIS7 WebSite.
Start a second instance of VS2010 in administrative mode and Attach to process w3wp.exe.
return to the first instance of vs and execute the method that has the breakpoint set.
Bringing back up the second instance of vs (the one that is attached), only shows "Disassembly cannot be displayed in run mode".
What did I miss? Is there a better way?
Any help or suggestions would be most appreciated.
Edit #1: I added debugging to the web.config, as:
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Still no luck??
Edit #2: In running the web service application project directly in its own instance of vs, I get
"The Web project "WCFServiceApplication0" is currently configured to
use the URL "http:/localhost:8999/WCFServiceApplication0". The Web server has this URL mapped to a different folder "C:\Nova5\WCFServiceApplication0_deploy". Would you like to remap this URL to point to the Web project's folder?"
How should this be answered? And how did a *_deploy folder get made? Thank you for your consideration.

You can directly debug your WCF service.
VS(Run as Adminstrator) -> Open the Wcf Project -> Properties -> Web
-> Point to the VirtualDirectory of IIS.
Then Right click the Svc.cs -> Debug as New instance.
If you have mulitiple hostable Projects in Solution Like 1 Web and 1 Wcf, then set Multiple StartUp Project from Solution -> Set StartUp project.

Related

How to create or attach WCF service in existing asp.net web site

i have already a web site which is live and hosted in ORCS Web developed using asp.net form project type. now i am planning to develop a wcf service which will be stored in a new folder of my existing website. we will use wcf service for uploading file from client machine to our web server. client can be any other .net based web apps or .net based win apps. i never work with wcf in production environment. so i want to know can i create that wcf service which will be stored in a new folder of my web site or do i need to host that wcf service separately.
if i can store the wcf service in my existing web site then how to deploy it? if i copy the dll file of my site and svc in our web server after development and testing then it would be sufficient or not for creating proxy from client side. actually any how i have to create wcf service in my site. i can not deploy the wcf service separately out of my website. so guide me how to deploy and what are the files i need to copy to my web server because first time i will be going to do this. thanks
You can add wcf service to existing asp.net application.
Open solution explorer right click on asp.net app project and select "Add" -> "New Item" and then select "WCF Service".
VS will modify your web.config by adding something similar to this, wcf server configuration:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
And now about deploying solution. It's never a good idea to do partial deploy. Please read one of my posts about this subject What files to upload when making a change in a webpage

Cannot create COM object

I'm debugging an application written in classic ASP. I'm using IIS Express 7.5 to be able to debug the application. All is fine, until I reach the following line:
set somevariable =Server.CreateObject("somelibrary.somemember")
"Unknown exception" is raised.
Context
I have administrative rights.
The OS is Windows XP SP3.
The "somelibrary" assembly was correctly registered with regasm and included in the GAC with gacutil.
I'm be able to execute the assembly from PowerShell:
$instance =New-Object -ComObject "somelibrary.somemember")
I have the following configuration in IIS Express for ASP:
<asp enableParentPaths="true"
bufferingOn="true"
errorsToNTLog="true"
appAllowDebugging="true"
appAllowClientDebug="true"
scriptErrorSentToBrowser="true">
<session allowSessionState="true" />
<cache diskTemplateCacheDirectory="%TEMP%\iisexpress\ASP Compiled Templates" />
<limits />
</asp>
The site has windows and anonymous authentication enabled (disabling windows authentication gets the same)
What could be the cause of the problem?
After a computer restart all is working fine. Looking in the event log I see entries indicating that there is no information about errors occurred in ASP and suggesting to use the /AUXSOURCE flag to get more details. I guess IIS Express lacks this help messages.

Service Reference in IIS

I know how to give service reference in Visual studio. Now I'm going to deploy the code in IIS server. there how to give Web reference (i.e Url of web service . Can any one help me.
In system 1 (Web application with web service) . system 2 (web application, web service has to fetched from system1). I can execute it in VS2008 because i can easily give service reference to system2 web application..
You don't need to add the reference again when deploying, but you may wish to change the address of the service, security information, quotas, timeouts, etc. All of this is configurable.
Web/service reference information is stored in .Net configuration files (e.g. app.config and web.config). When you deploy, you can change those values as needed to point to the correct location.
Example
Note the address attribute. This can be changed to the address where your endpoint resides.
<system.serviceModel>
<client>
<endpoint
address="http://localhost/SampleServer/PersonService.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_PersonService"
contract="People.PersonService" name="BasicHttpBinding_PersonService" />
</client>
</system.serviceModel>

WCF REST Service aspCompatibilityMode not working in IIS

Trying to deploy a wcf rest service inside of an asp.net web application. Works wonderfully when deploying to test server in visual studio, however when i deploy to iis 6 I get nothing. It is as if my service is not there at all.
here is my web config under system.service model:
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
and im registering a route in the global.cs
routes.Add(new ServiceRoute("Service", new WebServiceHostFactory3(), typeof(WcfJQueryService)));
my web service class is decorated with:
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
I am using windows authentication if that matters in this case...
Any ideas??
Got this to work via the instructions in this article...
http://hackprogrammer.blogspot.com/2009/01/installing-wcf-on-iis6.html
running aspnet_regiis -i for .net4.0 got me up and running

Hosting WCF web services on IIS - works in VS, but not in IIS

I'm very new in web programming stuff, so my question is about basics. I'm developing a SilverLight application and need to access the database from it. I'm using LINQ to SQL to get data from database and a WFC web service to deliver it to my app.
Everything is working fine when I'm running my app within Visual Studio. When trying to publish the web service to IIS - the web service call fails.
To make my question simple, I will focus on a brand new web service. Here the steps I'm doing:
Start Visual Studio 2008 -> File -> New -> Project -> Web -> WCF Service Application
Project Name: MyWcfService
Resulting Visual Studio generates a sample project with implemented Web Service "Service1"
Rebuild, start from Visual Studio (host on ASP.NET Development server)
--> Everything works fine, I see my service under http://localhost:52489/Service1.svc link
Now I want to host this service on my IIS (I've IIS7 on Vista x86 PC)
Visual Studio -> right click Project -> Publish -> target location -> Create new web app named "MyWcfService" -> Publish
Just to be sure check my C:\inetpub\wwwroot\ folder - now it contains the "MyWcfService" subdirectory with all required files.
Open IE on my PC http://localhost/MyWcfService/Service1.svc
The result is:
HTTP Error 404.3 - Not Found
The page you are requesting cannot be served because of the extension configuration. If > the page is a script, add a handler. If the file should be downloaded, add a MIME map.
I were trying to remove "identity" section from web.config - same problem. Switching off the firewall does not help either.
Can anyone help me? What I'm doing wrong? Maybe I am missing something?
Per Nicholas Allen, Program Manager WCF/WWF,Silverlight # Microsoft:
What registration in IIS is responsible for processing SVC files?
There are two parts to the registration. One part is related to ASP.NET and the other part is related to WCF. The ASP.NET part is that the ASP.NET ISAPI has to be a service extension for IIS. The WCF part is that the HTTP handler has to be a managed handler.
The commands for setting up the two parts are "aspnet_regiis –i –enable" from the 2.0 framework tools and "ServiceModelReg.exe -r" from the 3.0 framework tools.
This results in a managed handler "System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and an ISAPI module "%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" for *.svc files in IIS. In the IIS handler mappings, the managed handler has to be above the ISAPI module for this to work.
Together, the two parts start an HTTP pipeline and pass the resulting requests into WCF.
IIS will only direct requests to ASP .NET for certain files like aspx by default. I'm guessing that you don't have the svc extension mapped to asp .net. Try looking at this http://msdn.microsoft.com/en-us/library/bb515343.aspx.
Silverlight can only call web sevices in the exact same domain as the application (where the xap file lives)
To call a different domain you need to have a clientaccesspolicy.xml file where the web service lives. It's possible this is your problem.
<?xml version="1.0" encoding="utf-8" ?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from>
<domain uri="*" />
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true" />
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
You might not have ASP.Net setup properly in IIS. Take a look at this article:
http://msdn.microsoft.com/en-us/library/aa964620.aspx

Resources