Update service reference - Server Refused 127.0.0.1:Port - c#

My project has a bunch of projects and some of them consume a WCF one that is in the solution... Every now and then I have to update the service reference and i always get the same message saying that the server actively refused to answer as if there was no service there...
First I start debugging only the WCF project and test it using the WCF Test Client, and everything is fine...
Then, I open another VS instance, without closing the first one, open the same solution (again, not closing the first), start the WCF project, go back to instance 1, and update the service reference without a problem...
I think this is not how it's supposed to work... why can't VS start the WCF project, update the reference and then go on its way? is there a config i'm missing? perhaps something that another team member might have screwed-up in the past?!?
Details:
VS 2015
All projects on the same solution
All projects using same framework version
All projects using same architecture ref (x64)

In your situation (WCF project part of a solution including service consumers) I would not use a service reference. Service references are designed for when you are calling a service over which you have no control and to which you have no access.
You can call the service directly using ChannelFactory<T>.CreateChannel() - this removes the need for service references altogether and makes your code simpler and more readable.

Related

Visual Studio Express - Missing Project Subtype prevents opening of project

Am trying to create a WCF project by following the walkthrough here ... http://msdn.microsoft.com/en-us/library/bb386386.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-3, but got stuck at the first steps.
Bad - VSE Windows Desktop does not have the WCF service library templates.
Good - VSE Web Developer does, so I set up the WCF project in VSE Web Developer
Bad - Cannot open the WCF project in VSE Windows Desktop
Good - Find out that you can copy templates from VSE Web Developer Folders to VSE Windows Desktop, and I do
Good - VSE Windows Desktop now has WCF service library templates, so I try to create a new WCF project. VSE seems to comply, sets up the project folder ... but then
Bad - ... throws the error ...
The project file '... WcfService1.csproj' cannot be opened.
There is a missing subtype.
Subtype:'{blah blah}' us unsupported by this installation.
I even tried turning it off and turning it on again.
What next?
As I mentioned in my comment, a WCF Service Library is nothing more than a class library - the WCF Service Library project template just has additional stuff to make it quicker to set up the project. You can do the exact same thing by creating a class library.
Go to File -> New Project on the menu. In the window that opens up, expand Visual C#, then select Windows and select Class Library from the list in the center, give it a name and then click OK.
You'll have to add the Interface and the config settings for the service, but you should be able to copy and paste from the article you're following. Once that is done, voila, you have a WCF Service Library.
Edited for more details
The only thing the WCF Service Library template gives you is a boilerplate for a WCF Service Library - that includes the .cs file for the service implementation, the .cs file for the service contract (interface) That the service implements and an app.config file that has the necessary <system.serviceModel> entries.
Sticking with the article you linked to in your original post, here's how to do this without the template.
Step 1 and 2. Follow what I had above - create the class library. VS will create the project and you will see a file named class1.cs. This will be your service class. Rename it to WCFServiceLibrary1.cs if you desire.
Next add an interface and name it IWCFServiceLibrary1. This will be your service contract. You will need to update the WCFServiceLibrary1.cs file and add : IWCFServiceLibrary1 after the public class WCFServiceLibrary1, so it looks like this:
public class WCFServiceLibrary1 : IWCFServiceLibrary1
In the interface, add the [ServiceContract] attribute above the interface, like this:
[ServiceContract]
public interface IWCFServiceLibrary1
You will also want to add a reference to System.ServiceModel and using System.ServiceModel to your class and interface.
Step 3 and 4. Copy the code in the article to the proper files.
Step 5: You can test the service by hitting F5 and running the WCFTestClient.
You should then be able to follow the rest of the article.
It takes a little longer this way, but you will also gain a better understanding of what the WCF Service Library is.
Expectation management - I was expected to go through all the steps in the walkthough, but they might not be necessary (which is implied in the answers given). So, I tried a bare-bones set up, described here ...
Is it possible to start exploring WCF using Visual Studio Express for Windows Desktop 2013?

Visual Studio does not generate client proxy code when adding service reference

I have a WF [Workflow Foundation] project and when I try adding a service reference [Visual Studio 2013-Target Framework is 4.5.1] to it the generated reference code doesn't contain the client proxy code. I tried adding a service reference to other non WF projects [Library projects] and it works fine and the reference.cs contains the Client proxy code. Why Visual Studio doesn't generate client proxy for WF projects? If the facility is not there then obviously I am taking the wrong approach. How can I use a WCF method inside my CodeActivity?
Just to remind you that this is not the duplicate of the following thread :
Service reference not generating client types
Instead of a simple Reference.cs file Visual Studio kindly adds 7 more files to the service reference folder. When I recompile the project and build it all the methods of my WCF service appeared on the toolbox [and became available] and now I can use them in my Work Flows.

Cannot instantiate objectVO class from another project from WCF Service Library project even though they are in the same solution

I've been trying to create a webService on a .NET platform using Visual Studio's WCF Service Library project template. I noticed that when I tried to use a VO object from another project file within the same solution... programatically, the compiler has no issues and runs fine... but when I call the webService, it will stop the application prematurely.
I've done some google-ing and the closest answer I could find was the possibility that since WCF is run from a separate location, the VO.dll file that I added in as a reference is not available to it.
As a reference to the above statement... please find the enclosed link:
http://forums.asp.net/t/712261.aspx
Thanks

WCF reference.cs suddenly not including classes

I have developed a WCF service that has been working fine for a few weeks now. I publish this service to IIS directly from the development server. I have a dev test app that includes this WCF service as a Service Reference in its own project.
My WCF class library also references another project within the Visual Studio solution, and many classes are in the referenced project that are used by the service and calling applications.
Today, after publishing some changes to the service (I did not make ANY changes to the referenced project or its classes), three of about 20 of the classes in the referenced project are no longer in the service reference of my test app. I cannot use them in code any longer, and they are no longer in the Reference.cs. I double checked, the classes in question are still decorated with [DataContract] and the properties are all still decorated with [DataMember] in the service solution.
Everything is building in Visual Studio OK.. I have rebuilt and republished everything, the missing classes are set to compile, I have tried IIS resets, completely deleted the IIS site and did a clean republish, no avail. I have tried deleting the service reference on the test app and getting a clean proxy every time as well. Nothing is working.
I then tried making a dummy class in the referenced project and built it in. Republished the service again, and even this dummy class does not appear in the Reference.cs. I am at a complete loss as to why these classes are not included in the .dll for the referenced project after it is published as it is evident that everything is building OK in Visual Studio.
I face such problem.
Following steps help you
1. Right click on Service ( In Service Reference Section of Project)
2. In Update Service Reference click on Advanced
3. Do as attached image.
Wanted to come back and post what was causing my problem:
I had made changes and none of my service methods used the 3 "missing" classes as a return type or parameter anymore. I simply had to un-comment the methods that used those classes to make them usable again. Makes sense now but I was convinced something else was wrong.
I faced similar issue and resolved it by doing the following.
Add the address of your end point with mexHttpsBinding.
E.g., Lets consider the address as mex.
While configuring service reference append /mex at the end of your service URL.
https://service.domain.com/serivce1.svc/mex
This will enable metadata exchange. So Reference.cs will be modified / added (if you are adding service reference for the first time).
Please Make sure that your service has an end point with mexHttpBinding / mexHttpsBinding
Edit : On analysis I found that this issue happens when the service is exposed via more than two end points (including mex end point)

Loading Native Managed and C++ DLL within IIS 7 for WCF Project On Runtime

I have WCF service developed in C# for with .NET framework 4.0 for IIS v7. My service using some managed VC++.NET DLL's which internally relies on some native C++ DLL's.
Now I have following options to proceed;
1) Publish all my managed DLL's in GAC (Global Repository)
2) set PATH environment variable, re-start my machine so that IIS (7) server can pick up the changes.
But client does not want both of the above solution because of following reasons;
1) They do not want anything available globally
2) Setting PATH, re-start the machine for every service deployed....NAAAAAH!!!!
So I researched and then I found I can set the environment on runtime, so I added some properties within my Web.config file and thought of appending my environment for each service on runtime. But the problem is that where should I write this peace of code as if I append this code in service class IIS will fail as it will try to resolve all the dependencies but fail as my code is not ran yet.
Now I want, a way to split my code which set up the environment in separate class for each service on startup of the service and called that in the end when we un-deploy.
I am not sure if it is even possible?
P.S Please bare in mind I am new to WCF and .NET stuff.
Your help and comments will be appreciated.
--
SJunejo
If yout don't set the Delay Load Property all referenced unmanaged DLLs will be loaded before your global.asax code is executed, so it's still looking in the wrong place.
You should follow all steps in Option 2b) if you want it to work.

Categories