wcf : Service + Client in same solution, how to debug? I don't want to run 2 versions of VS 2010 at the same time - wcf

I have created an application which has a client (WPF) and the Server (WCF), the service is IIS hosted, currently I am having to have 2 versions of vs 2010. One loads the wcf service in IIS and the other in my windows application.
The problem with this is it takes so much resources.
It appears if the wcf service is "NOT" hosted in IIS then I can start two projects at the same time according to this http://msdn.microsoft.com/en-us/library/bb157685.aspx
But what are my other options?
I need to find the best way of being able to compile / run the 2 projects and able STEP INTO each when when in debug, without using too many resources or having more than one vs 2010 open at the same time.

You should be able to debug both from the same instance of Visual Studio if they are in the same solution. When you run your application from Visual Studio, open the Debug menu and choose Attach To Process, you need to attach the debugger to the ASP.NET worker process (aspnet_wp.exe), it should automatically attach to your client.

Open service and client code in VS. Open Debug menu. Attach to process. Hold the Ctrl key and select as many processes as you want to debug using Mouse click.
In your case, you can select the ASP NET worker process depending on the version of IIS and the client process.

The easiest way to debug your WCF service is to:
Right click on project containing svc file.
Select Set as Startup project.
Put a breakpoint on the methods you want to debug.
Breakpoint should be Red.
Make sure your app config file is pointing to the debug WCF service version that's currently running, ex:
http://localhost:12345/MyService.svc
Run your app.
When the app calls that WCF method, it should stop on breakpoint.

Related

Running winforms client, does not start iisexpress with the referenced wcf service - under Windows 10. Ideas?

I have a vs solution with 2 projects - WinForms client, and WCF Service.
Since visual studio 2013 to 2019 (I was under Windows 7), every time when I ran in debug the WinForm client, VS automatically was starting the IISExpress in background(I want that!), and my calls from the client were successful, stopping on breakpoints inside the WCF service easy.
Last week, I got new box with Windows 10. Now when I start the client, there is no iisexpress.
The source code is the same and not changed - my co-workers are under Windows 7 and this works for them - same code - we use git as version control.
The only time I see iisexpress is if I do "Update Service Reference" or I make the WCF startup project and run it.
Can you help me identify why this functionality stopped working? Ideas for a fix?
Windows 10, Visual Studio 2019 Enterprise, .NET 4.6
EDIT: I do not have problem running the webservice in IISExpress, when i specifically run it - it works, also on solution level if I set 2 startup projects, all will work. The main issue is that with Single Startup project - thw WinForms client, Visual Studio will not bring up the IISExpress instance. It is only development time issue, and this works for my co-workers.
The solution is in the VS generated (regenerated if missing) user file in the WCF project
.csproj.user
there is property
<AlwaysStartWebServerOnDebug>True</AlwaysStartWebServerOnDebug>
It must be True, but now it is defaulted to False.
The *.user files do not go to version control, and if they are missing VS regenerates them, hence my coworkers had it, and my freshly cloned repo did not.
I'm pretty sure I never touched this file or did any configs like that on the WCF project, my suspicion is that MS decided to start defaulting to False in some version or patch.
WARNING! After changing the option, close/open the entire solution or restart VS.
Disclaimer: I found this solution in the build in VS report problem button leading to a portal with reported problems and solutions. I do not see how to copy link or anything from that Feedback tool, but this is the guy that deserves the credit: 佐々木隆幸
It seems that you want to debug the WinForms application separately regardless of the WCF application. we could set up the project dependencies in the property page of the VS solution.
Then open the SVC file, press F5 to launch the WCF application so that we can add service reference in WinForms application.
Please ensure the below configuration in the property page of the WCF application project.
Besides, if there is something wrong with the IISExpress, we could opt to repair the IISExpress in the below dialog.
On my side, it works like a charm.
Feel free to let me know if the problem still exists.

How to startup and use WCF service in another project

I created a WCF Service Application project in VS 2012. Implmenented the service.
here is what it looks like:
Now I have a fundamental issue to deal with. I created a new Test project to create more TDD and also some TAD tests. The TAD (Tests after Implementation) tests will test the service implementation while my TDD test will test reliant on mocking my WCF Servcie Interface.
But now going back to my TAD tests which need to test using an implementation of the service. I take that is I'm adding a service reference and using the clientProxy in my unit tests for TAD.
So I add a service reference to a new C# Project. I then continue to create some tests such as:
[TestMethod]
public void Get_CalledViaClientProxy_ReturnsNonNullList()
{
var serviceClient = new CarsClient();
// Act
Cars[] events = serviceClient.Get();
// Assert
Assert.IsNotNull(events);
}
When I run this it fails because the actual service is not running. So what I've done is go back to the actual Service WCF project, right-click the service (.svc) and choose to open it in the browser which will also start the service under IIS Express. Then my tests run fine.
So from that, how do I make this more automated. If another dev downloads this code, those tests should run and the service should somehow be started. I tried to set my service project as the startup project but all that does is opens the browser to show me the file system for that project.
How do people run the service for testing other than in IIS? and make it so it just works for devs? If I can't get my service to run simply but pressing F5 somehow and still able to go back into my tests project to try and run unit tests then this is pointless.
When I simply try to set my "WCF Service Application" project to be the startup project, instead of just starting the service and sitting there with a console window, it opens a web page for the service. Do I have the wrong WCF project type? I noticed that I have a web tab because I've got a "Serviced Application" project, should I be using something else if I want to simply start up my project in VS and continue coding in other projects that utilize this running service?
At a previous company I was at, we all put a "-d" in the WCF service project which when you ran the project it would start the service and a console window would run and just sit there, then you knew the service was running while you continued on writing TAD unit tests against it
e.g.:
however again, my WCF project is a "WCF Application Service" so I don't have that exact debug tab in mine so not sure what to do and then how we were able to have this format of tabs in the WCF service at other places I've been. Maybe it's just a plain C# project, not a WCF project where we were putting the -d but then how was it starting the WCF service if that was the case? Not sure if it was a plain vanilla C# project that we put that -d in but I sure do not have this same tab format in my WCF Service Application project.
Update #2
Ok I just to see the diff, added a "WCF Service Library" project along side my "WCF Service Application" project. The tab now has that debug and now when I launch it it does start the service and the test client comes up because the VS template automatically has /client:"WcfTestClient.exe" in for the command line properties of the debug tab in the project properties.
Since this service is going to serve as a service API that will be used cross applications, maybe I shouldn't be using a "WCF Service Application" and should be using a "WCF Service Library" type of WCF project template.
Refer your wcf project from the same solution as your test project.
Right click solution -> set startup projects
choose multiple startup projects and change the action of your wcfservice from none to start or start without debugging. Play and test :)
Or start project without debugging, wcf service will be running and you can continue coding/building and testing.
EDIT:
Here is what you also could do;
Change your wcf project to wcf service library, make sure this project have the following config...
under debug:
Start action: Start project
Start options: command line arguments: /client:"WcfTestClient.exe"
under wcf options:
Check "start wcf service host when debugging another project in the same solution"
Under solution -> startup projects, make sure you have a single startup project.
This way you can debug your other projects in the solution, visual studio will ensure that your wcf service is started.
You can host your service in local IIS automatically by configuring project settings from Visual Studio. Then whenever you compile your WCF service, IIS hosted instance will be updated and ready to serve automatically.
Right click your WCF Service project -> Properties -> Web -> Use Local IIS Web Server and click Create Virtual Directory. Before, do not forget to turn on your IIS services feature on your machine if not.
Additionally, why dont you test your concrete service implementation only just by referencing it, you dont need to run a service and connect it to test your business.
Usually you put WCF service logic in some other project, let say "WCF Login Library" and you test functions on that. You don't need wcf service to test those method calls. You can then use only one method to test the connection with WCF (that's usually done manually by me).
Isn't that simpler approach?

IISExpress: Unable to automatically step into the server. the remote procedure cannot be debugged

I'm hosing a webservice in IISExpress and can browse to the endpoint using my browser so I know its alive. I'm writing a test application in WinForms and want to call a method on the service.
When I try and step into the call, I get this error.
IISExpress: Unable to automatically step into the server. the remote procedure cannot be debugged.
The webservice is set to be in debug mode, I'm wondering is there some setting which is preventing IISExpress from allowing debugging?
Update:
I'm wondering if this is because the Test app doesn't have any .pdb files loaded into memory as these are stored elsewhere within the webservice folder, NOT the test app bin folder.
I've tried to specify the folder of the bin folder where the app_code.pdb is located for the webservices, but still not luck.
So how is this done? I'm stumped.
Update 2:
Still haven't been able to get this to work after a week of looking into it.
So here are my basic requirements: I need a 1) WinForms app to 2) be able to make calls to different webservices and 3) be able to step into each service call. The services are hosted as sub-applications of a root website using IISExpress. The WinForm test app is making the web service calls, but IISExpress is started via a Nant task. The webservices are old web site type projects, so they have app_code.dll files. I've tried setting symbol paths up to point to the built pdb file, but I then get an error along the lines of:
"A matching symbol file was not found in this folder".
I never thought debugging webservices would be this difficult?!?
1) Reference the DLL of your webservice in your test project.
2) IISExpress is a completely different application then your winforms application, just having the DLLs referenced still won't automatically allow you to step into your web service code. You need to attach to the IISExpress.exe process. When you start your winforms project, Hit Debug...Attach to Process and choose IISExpress.exe. Now you should be able to actually step into your web service code.
I realize this is a late response but it's something I've run into (especially after having stepped away from a WCF project for long periods of time).
Make sure you have your breakpoint set in your "server-side" service class code...and not in your "client-side" calling code. This is so the server side service has the necessary debug info (your breakpoint) compiled into the .pdb file on the server.

How can I stop VS2010 from lauching the wcf host when it's not needed?

I imported a vs2008 solution containing a class library with a wcf service defined in it. The solution also contains a console project which holds the hosting app for the service. The console app is set as the startup project. When I hit Debug, the console app tries to open the service host, but vs2010 also launches the generic WcfHost. This causes console app to crash.
How do I stop the WcfHost from launching and competing with the console app that hosts the services too?
or should I stop the console app from hosting?
Not exactly sure about VS2010, but in VS2008, right-click the class library project w/ the WCF service in the Solution Explorer and select Properties. You should see a WCF Options tab. That tab has a checkbox that, to the best of my recollection, is checked by default. I have long since unchecked it, but it controls the startup of the WcfHost. Again, I'm not sure about VS2010, but I would look for a project property setting that controls this.

Problems with debugging in Silverlight 4 using Out of Browser and WCF RIA Services

With Visual stuido 2010, it's simple to set up SL4 to debug with an out-of-browser installed app. I followed the instructions from here and everything seems to set up fine. Debugging from the browser runs the program just fine, but running from the OOB program gives a different result. After starting, the screen will go blank and then hang forever. I have some concerns that it might be because of some of the technologies that we're using.
Firstly, there's a popup that happens because we're using WCF RIA Services (formerly .NET RIA Services).
"RIA Services will fail unless the silverlight project is hosted and launched from the same web project that contains the RIA Services."
This seems to just be a warning, but I have a suspicion that this warning might be telling me that RIA Services needs to have the .web project as its startup project.
We're also using prism and the error has an odor of a Prism error too. (something loading and then not ever appearing)
Has anyone else had any issues with OOB debugging in SL4? Is anyone else OOB debugging in SL4?
Sorry it's so vague. It's a complicated mess. The only message I see is the italicized popup warning. Then the window (which was previously showing the background of our application) just goes blank
There is currently a known issue with debugging an Out of Browser Silverlight 4 application when using F5 to launch the application from within VS 2010. The question I have is whether or not the application launches without debugging (-F5 or running it from the shortcut)? In the case of using F5, a dialog typically appears with the following error dialog “Unable to start debugging. A fatal error occured. For more details, please see the Microsoft Help and Support web site. HRESULT=0x80070018” and then the application appears to hang. In this case detaching allows the process to continue and then reattaching should allow you to debug the process.
If this is completely blocking or you’re trying to debug code running at startup (like the page startup event), one possible way to get around this would be to put in a call to System.Diagnostics.Debugger.Break, start the program and then attach when dialog pops.
This can be caused by the OOBA install being older than the version you are trying to debug. Remember, Silverlight OOBAs do not automatically update themselves to the latest version of the XAP file that may be available on the server. You have to update them yourself. If you get this error and you have included the auto-update logic in your app, just bounce out of VS, run the app so it auto-updates, then go back in and debug.
Alternately, you can uninstall the app and re-install it. That will ensure you are debugging against the latest VS build.
I ran into this same issue with VS 2008 and Silverlight 3. If I got it, I just jumped out and updated the app then re-ran it in VS and had full debugging.