Visual Studio cannot remove Service Reference - visual-studio

I am using vs2013 and vs2015 and cannot remove the service references:
a normal right click and then delete show do the job (or the delete key on the keyboard when selected)
But I get:
The configuration for the service reference could not be deleted due to the following issue: An error occurred creating the configuration section handler for system.serviceModel/bindings: AssemblyResolveEvent handlers cannot return Assemblies loaded for reflection only.
Here is the part of my web.config (line 249 and more)
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="PayPalAPISoapBinding">
<security mode="Transport" />
</binding>
<binding name="PayPalAPIAASoapBinding">
<security mode="Transport" />
</binding>
<binding name="PayPalAPISoapBinding1" />
<binding name="PayPalAPIAASoapBinding1" />
<binding name="PayPalAPISoapBinding2">
<security mode="Transport" />
</binding>
<binding name="PayPalAPIAASoapBinding2">
<security mode="Transport" />
</binding>
<binding name="PayPalAPISoapBinding3" />
<binding name="PayPalAPIAASoapBinding3" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://api.sandbox.paypal.com/2.0/" binding="basicHttpBinding" bindingConfiguration="PayPalAPISoapBinding" contract="PayPalSvc.PayPalAPIInterface" name="PayPalAPI" />
<endpoint address="https://api-aa.sandbox.paypal.com/2.0/" binding="basicHttpBinding" bindingConfiguration="PayPalAPIAASoapBinding" contract="PayPalSvc.PayPalAPIAAInterface" name="PayPalAPIAA" />
<endpoint address="https://api.sandbox.paypal.com/2.0/" binding="basicHttpBinding" bindingConfiguration="PayPalAPISoapBinding2" contract="PayPalLive.PayPalAPIInterface" name="PayPalAPI1" />
<endpoint address="https://api-aa-3t.sandbox.paypal.com/2.0/" binding="basicHttpBinding" bindingConfiguration="PayPalAPIAASoapBinding2" contract="PayPalLive.PayPalAPIAAInterface" name="PayPalAPIAA1" />
</client>
</system.serviceModel>
I referenced the WSDL from paypal years ago and rebuild the whole thing using the nuget package (REST instead of the old soap api)
But I cannot cleanup the old wsdl code and (service)references.
I got the same error if I deleted the web.config part and deleted the reference afterwards.

Steps to manually fix it:
Removed the client and bindings part from the system.serviceModel in the web.config manually.
Removed the service reference dir from the filesystem
manually edited my *.csproj file. (Searched for paypal and removed everything except the new nuget reference. Also removed the "service reference" reference from the csproj.)

Delete web.config then delete the service reference.
Restore the web.config afterwards and clean up any binding references.

Related

Deploying a WCF service to IIS 6

I created a wcf service using VS2010 and it works correctly, when I run it from VS2010, but when I deploy it on IIS 6(according this post), It does not work.
I did this steps:
I created a folder in my server(C:\WCFServices\HRService) and copied HRService.svc and web.config to it and grant full access to this folder for ASPNET user.
I created a Bin folder in the above folder and copied my service dll in it.
I Created new virtual directory in my default web site(HR):
My .svc files , web.Configs are as below:
My .svc file
<%# ServiceHost Language="C#" Debug="true" Service="HumanResourceService.HRService" %>
And my web.Config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="NewBinding0" />
</basicHttpBinding>
</bindings>
<services>
<service name="HumanResourceService.HRService">
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="" contract="HumanResourceService.IHRService" >
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
But when I want to access my WCF service via IE I get this error:
Could anyone tell me, what is the problem?
Make sure the the name for the service in the configuration file matches the .svc file. In your posted code it doesn't. Your .svc file has "HumanResourceService.HRService", so the name attribute for the <service> element should match:
<service name="HumanResourceService.HRService">
Also, is this a RESTful service or SOAP? I ask because you are using the webHttpBinding for your service, which is for REST. If it's not, I suggest basicHttpBinding or wsHttpBinding.
If it is REST, then add this to the behavior section of your config file:
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
I found the problem.
In IIS and in Web Service Extensions section, the ASP.NET V4.0.30319 status was Prohibited and I changed it to Allowed and the problem solved.

WCF Service, the type provided as the service attribute values...could not be found

I have this issue a long time ago and just cannot recall how to resolve it or perphaps its something new. I created a WCF service which I will later use in web application that calls the WCF service amongst others from a remote location. Right now I am trying to host in IIS and even tried the WCFTestClient. The error I get when I try to browse to the service; is the following:
The type MyService.Service1 provided as the Service attribute
value in the ServiceHost directive, or provided in the
configuration element system.serviceModel/serviceHostingEnvironment/
serviceActivations could not be found.
I figured its probably my web.config file but I cannot see whats wrong:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<bindings>
<webHttpBinding>
<binding name="webHttpBinding" crossDomainScriptAccessEnabled="false" />
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="webHttpBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="webHttpBehavior" name="WcfInstanceRules2.Service1">
<endpoint address=""
binding="webHttpBinding"
contract="WcfRules2.IServiceS" behaviorConfiguration="web"/>
<endpoint address="mex"
binding="webHttpBinding" contract="IMetadataExchange"></endpoint>
</service>
</services>
I would like this to be eventually a rest service delivering data in json format.
Check your .svc file and see what service it's referencing - probably MyService.Service1, which doesn't exist in your config. It looks like it should be referencing WcfInstanceRules2.Service1.

Visual Studio "Add Service Reference" - not gets all service settings

my purpose is to ensure that - when someone clicks on "Add Service Reference" in his own Visual Studio, and he adds references to my WCF service - he receives not the default settings, but the settings of the service.
In particular, there is a property of the "binding" class that interests me: useDefaultWebProxy, I need it setted to "false".
I tried this, but with no results:
In the Web.config file of the service:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="NewBinding0" ... useDefaultWebProxy="false">
<readerQuotas ... />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="NewBehavior0" name="pippo.pluto">
<endpoint address="" behaviorConfiguration="" binding="basicHttpBinding"
bindingConfiguration="NewBinding0" name="pluto" contract="pippo.ipluto" />
<host>
<timeouts ... />
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="NewBehavior0">
<serviceMetadata ... />
<serviceDebug ... />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
Nothing to do: in the client's Web.config I always get...
<basicHttpBinding>
<binding name="pluto" ... useDefaultWebProxy="true">
<readerQuotas ... />
<security ...>
<transport ... />
<message ... />
</security>
</binding>
</basicHttpBinding>
It seems that the bindingConfiguration of the service is completely ignored, not only useDefaultWebProxy but also other properties - for example maxBufferSize - maintain the default values (65536)
How can I do?
Pileggi

Hosting the same WCF Service in IIS and in Windows Service

I am trying to decide on an architecture for a change in my web service. I need to make a WCF service. I want to make only one service and then host it either in the IIS or in a Windows service. Is this even possible, making this kind of reuse of a WCF Service? How would I go about doing this? The scenario is that some of our customers do not have access to start a Windows service but can install a WCF in the IIS.
Thank you in advance.
A WCF service is simply an assembly that abides by the WCF hosting interface and then provides a client interface that allows it to be accessed.
Hosting a WCF service occurs equally in IIS, Windows service, WinForm application, or a console application. It truly doesn't matter.
The client interface remains unchanged, although how the interface is exposed might change depending on hosting scenario. For example, you'll probably use one the http bindings in the IIS case, but might use TCP binding for Windows services. These bindings can be defined in the config file, so the code doesn't necessarily have to change to accommodate being hosted one way or the other.
In short, creating the WCF service should be independent of how it will eventually be hosted. For ease of maintenance on your part, though, I'd pick one or the other - Windows service or IIS.
you could have a windows service host the WCF and expose all end points on it..Http,TCP..
Windows service is better than IIS because IIS is a process in itself and then we place upon it a VD to host our website/WCF.As for the Windows Service,it will be one dedicated thread catering only to the WCF.I am sharing the app.config of windows service (details changed) to show how we have hosted WCF...hope it helps..
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Off" propagateActivity="true" >
<listeners>
<add name="SERVICE_MONITOR" type="System.Diagnostics.XmlWriterTraceListener"
initializeData="MyApp_MONITOR.svclog" />
</listeners>
</source>
<source name="MyApp_TRACE" switchValue="All" >
<listeners>
<add name="MyApp_TRACE_LISTENER" type="System.Diagnostics.XmlWriterTraceListener"
initializeData="MyApp_TRACE.svclog" />
</listeners>
</source>
</sources>
<trace autoflush="true" />
</system.diagnostics>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="OverAllServiceBehavior">
<serviceSecurityAudit
auditLogLocation="Application"
serviceAuthorizationAuditLevel="Failure"
messageAuthenticationAuditLevel="Failure"
suppressAuditFailure="true" />
<serviceDebug includeExceptionDetailInFaults="True" />
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
<serviceThrottling maxConcurrentCalls="10000" maxConcurrentSessions="10000"
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceCredentials>
<userNameAuthentication
userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="MyAppHost.Authenticate, MyAppHost"/>
<serviceCertificate findValue="MyApp_MESSAGE" storeLocation="LocalMachine"
storeName="My" x509FindType="FindBySubjectName" />
<clientCertificate>
<authentication
certificateValidationMode="PeerTrust"
trustedStoreLocation="LocalMachine" />
</clientCertificate>
</serviceCredentials>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="OverAllEndPointBehavior" />
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="ServiceBasicHttpEndPointBinding" closeTimeout="00:00:59"
openTimeout="00:00:59"
messageEncoding="Text"
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="Message">
<message clientCredentialType="Certificate"/>
</security>
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="ServiceWSHttpEndPointBinding" closeTimeout="00:00:59"
openTimeout="00:00:59"
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message clientCredentialType="Certificate"/>
</security>
</binding>
</wsHttpBinding>
<netTcpBinding>
<binding name="ServiceTCPEndPointBinding" maxBufferSize="2147483647"
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="TransportWithMessageCredential">
<transport
clientCredentialType="Certificate"
protectionLevel="EncryptAndSign" />
<message clientCredentialType="UserName" algorithmSuite="TripleDes"/>
</security>
</binding>
</netTcpBinding>
</bindings>
<services>
<service behaviorConfiguration="OverAllServiceBehavior"
name="MiddleWare.ServiceClasses.ServiceClass">
<host>
<baseAddresses>
<add baseAddress="net.tcp://127.0.0.1:15010/ServiceTCPEndPointMEX"/>
<add baseAddress="http://127.0.0.1:15020/ServiceHttpEndPointMEX"/>
<add baseAddress="https://127.0.0.1:15030/ServiceWSHttpEndPointMEX"/>
</baseAddresses>
</host>
<endpoint address="net.tcp://127.0.0.1:15040/ServiceTCPEndPoint"
contract="MiddleWare.ServiceContracts.IServiceContract" />
<endpoint address="http://127.0.0.1:15050/ServiceBasicHttpEndPoint"
contract="MiddleWare.ServiceContracts.IServiceContract"/>
<endpoint address="https://127.0.0.1:15060/ServiceWSHttpEndPoint"
contract="MiddleWare.ServiceContracts.IServiceContract"/>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
<appSettings>
<add key="UserName" value="USER"/>
<add key="Password" value="PASSWORD"/>
</appSettings>
</configuration>

Why do I need to rebuild a WCF AJAX Service that didn't change while debugging?

I have a WCF based service that I use to expose AJAX functionality. Sometimes the service fails when I start a new debugging session (even if I make no changes to the service itself). A rebuild all fixes the issue. I never have this issue in production, just while debugging. I use IIS 7 to debug and have disabled all recycling. Below is my config.
Does anyone know why this happens? Is there another way I can configure the service?
Thanks!
Jon
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="SomeService.MyAjaxServiceAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service name="SomeService.MyAjaxService">
<endpoint address="" behaviorConfiguration="SomeService.MyAjaxServiceAspNetAjaxBehavior" binding="webHttpBinding"
bindingConfiguration="webBinding"
contract="SomeService.MyAjaxService" />
<endpoint address="" behaviorConfiguration="SomeService.MyAjaxServiceAspNetAjaxBehavior" binding="webHttpBinding"
bindingConfiguration="sslWebBinding"
contract="SomeService.MyAjaxService" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="sslWebBinding">
<security mode="Transport">
</security>
</binding>
<binding name="webBinding">
<security mode="None">
</security>
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>
I ended up having to add batch="false" in the web config. I still need to investigate the full ramifications of this, but at least I don't have to rebuild the service all the time.
Cheers,
Jon

Resources