Configuration binding extension 'system.serviceModel/bindings/pollingDuplexHttpBinding' could not be found - c#

Problem
I'm getting the following error whenever I try to load out .svc url (Local)
Configuration binding extension 'system.serviceModel/bindings/pollingDuplexHttpBinding' could not be found. Verify that this binding extension is properly registered in system.serviceModel/extensions/bindingExtensions and that it is spelled correctly.
Enviroment
The project was build by a ex colleague of mine, who I can't reach. It's a webservice build in .Net Framework 4
I get this error when I attempt to gain access to our .svc file
In the web.config I have this setting:
<system.serviceModel>
<extensions>
<bindingExtensions>
<add name="pollingDuplexHttpBinding" type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement, System.ServiceModel.PollingDuplex, version=3.0.0.0, Culture=neutral" />
</bindingExtensions>
</extensions>
which is later used as <endpoint address="" binding="pollingDuplexHttpBinding" contract="<ourcompany>.DataService.IMessageService"/>
Attempts
In regards to other posts about this error I have already tried:
Installing Dot net 3.5 SP1
Removing the line from web.config
Reinstalled IIS
I have no idea what to do, or how to fix this.
The strange part is that it does work on our live server, but not on my own computer for testing purposes!

Refer - Unrecognized element 'pollingDuplexHttpBinding' in service reference configuration
<!-- Register the binding extension from the SDK. -->
<extensions>
<bindingExtensions>
<add name=
"pollingDuplexHttpBinding"
type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement,System.ServiceModel.PollingDuplex, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</bindingExtensions>
The difference here is, Version=4.0.0.0 and PublicKeyToken=31bf3856ad364e35.
You can get more information on the Section "To use PollingDuplexHttpBinding" section of - How to: Build a Duplex Service for a Silverlight Client.
Good luck. :)

Related

Header behaviour in a virtual MVC application in IIS

This is my current setup;
In IIS I have two hosted MVC applications, say App1 is hosted in app1.mydomain.com. It has a virtual MVC application (not directory) App2 hosted as app1.mydomain.com/app2.
Both applications have a connection to the same WCF service. This WCF service requires headers in their requests and thus I have added behaviours for every call using this.
I have configured both applications' header behaviour correctly (App1 has App1MessageHeaderInspector and App2 has App2MessageHeaderInspector) and have configured both in their own Web.config.
So, App1 uses;
<client>
<endpoint address="http://ws.mydomain.com/Service.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IWebService" contract="WCFService.IWebService"
name="BasicHttpBinding_IWebService" behaviorConfiguration="WebServiceEndpointBehaviour" />
</client>
<extensions>
<behaviorExtensions>
<add name="App1MessageHeaderInspector" type="App1.App1MessageHeaderBehaviourExtension, App1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null "/>
</behaviorExtensions>
</extensions>
<behaviors>
<endpointBehaviors>
<behavior name="WebServiceEndpointBehaviour">
<App1MessageHeaderInspector />
</behavior>
</endpointBehaviors>
</behaviors>
And App2 uses the same configuration, except that App1MessageheaderInspector is App2MessageHeaderInspector.
I have configured my routing in App1 to ignore everything going to /app2;
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{*path}", new { path = #"app2\/(.*)" });
//...
}
And I can succesfully view pages which do not require a connection to the WCF service (i.e. app1.mydomain.com/app2/Home/Index returns the correct view).
Now my problem is, as soon as I try to connect to the WCF service with App2, I get the following error;
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: The type 'App1.App1MessageHeaderBehaviourExtension, App1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null ' registered for extension 'App1MessageHeaderInspector' could not be loaded.
But I don't want App2 to load the behaviours from App1!
I have also tried to encapsulate <system.web> with <location inheritInChildApplications="false"> in App1, but without success.
Both applications work as intended when testing from my local PC. There is no Windows authentication or anything like that involved.
I am quite stuck on this topic for a few days now. Any help is appreciated.
Configuration section are inherited/merged by default when a web application is configured under another one like in your case. As you've seen system.web section has its mechanism to break inheritance, but this just works for system.web and its children (possibly, not even all children).
Having said that, I would give a try at this (in your App2 config):
<extensions>
<behaviorExtensions>
<clear />
<add name="App1MessageHeaderInspector" type="App1.App1MessageHeaderBehaviourExtension, App1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null "/>
</behaviorExtensions>
</extensions>
Do you have the App1.dll in your bin directory under the virtual directory for app2? The message indicates that the dll cannot be found in the usual location (such as /bin)

Change Build Output Directory of WebApi Application

I am part of a team working on a large application. I am a new addition to this team and am building a new piece of the app. As part of this process, I've created a WebApi application that will expose some HTTP endpoints through which I will retrieve information about the app.
Due to conditions it would take far too long to explain, I'd like to get the WebApi project to build in another directory, specifically ..\bin\Server\Debug\ as this is where most of the other portions of the app build to. I would not bother except that the app tried to use files that are found based on the working directory which is currently wrong for my WebApi app.
I tried changing it in the project settings and now I get this error:
My Googling has turned up little help thus far. Anyone know how to resolve this?
Try adding a runtime probing path in the configuration:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="bin\server\Debug;"/>
</assemblyBinding>
</runtime>
</configuration>
In addition to above step and to get rid of globa.asax error. Open the mark up of Global.asax file and Add follow line on the top.
<%# Assembly Name="<you_web_app_assembly_name_here>" %>
Now you'll start getting the error of System.web or BindingProvider not found etc. There's weird fix for it start adding assemblies to assembly tag under compilation.
<compilation debug="true" targetFramework="4.5" optimizeCompilations="false">
<assemblies>
<add assembly="Microsoft.AspNet.Identity.Core, Version=2.2.1, PublicKeyToken=31bf3856ad364e35" />
<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Optimization, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</assemblies>
</compilation>
You'll get few more errors like this but this will get you going.
Reason: The problem I see is that there's an option to change the output path but Asp.net does on the fly compilation. Which why the error are compilation related when you try to run the website. Somewhere the run time compilation only look in \bin folder and which is why we have to specify every assembly that the project is referencing to.
Update -
Unfortunately you can not change the bin directory. After looking at all options and digging found that bin folder of Asp.net web project is not ordinary binary output folder. It's a share code folder from where the binaries are referenced directly in the project.
The binaries are compiled when a first request is received by webserver for Asp.net application. And bin folder is only use as shared binary references folder and not the actual output folder/directory.
The actual output folder of On-the-fly compilation in Asp.net is default set to %SystemRoot%\Microsoft.NET\Framework\<versionNumber>\Temporary ASP.NET Files that you can change ofcourse from compilation tag attribute [tempDirectory][3] in your web.config.
After all these research I came to this conclusion that the option for changing the directory from project -> properties -> Build -> Bin is appearing because of Asp.net website project template. This gives the user same look'n feel as any other project. But the functionality of asp.net website remains the same. The Bin folder still works as it used to work in old website template of Asp.net.
You cannot change the output directory of an asp.net application due to IIS security restrictions, this is why it is not working.
If you are trying to manage dlls due to DI, copy all other satellite dlls into bin folder of your main asp.net app
You can try copying the dll with the after build target. First change the output path back to what it was if you changed it before. Then add some code like this in your project file.
<target name="AfterBuild">
<copy destinationfolder="..\bin\Server\Debug\" overwritereadonlyfiles="true" sourcefiles="$(OutputPath)\$(AssemblyName).dll" />
<copy destinationfolder="..\bin\Server\Debug\" overwritereadonlyfiles="true" sourcefiles="$(OutputPath)\$(AssemblyName).pdb" />
<copy destinationfolder="..\bin\Server\Debug\" overwritereadonlyfiles="true" sourcefiles="$(OutputPath)\$(AssemblyName).xml" />
</target>
This will put the built dll in to the folder specified in destinationfolder. I usually use this for class libraries but i don't see why it would not work for a web api project
You can check out my blog post on this if you like.
http://torontoprogrammers.blogspot.com/2014/11/msbuild-targets-and-tasks.html

WCF configuration tool dont like behaviorExtensions?

When trying to open my web.config with the Microsoft Service Configuration Editor I get exceptions about not finding extensions. The WCF application works fine with the extensions and if I remove them, then the Microsoft Service Configuration Editor will open the web.config without problem?
<extensions>
<behaviorExtensions>
<add name="protobuf" type="ProtoBuf.ServiceModel.ProtoBehaviorExtension, protobuf-net, Version=2.0.0.580, Culture=neutral, PublicKeyToken=257b51d87d2e4d67" />
<add name="customBehaviorExtension_Integration" type="MyApp.ServiceImplementation.CustomRequestInterceptorBehaviorExtension_Integration, MyApp.ServiceImplementation" />
</behaviorExtensions>
</extensions>
These extensions are used in 3 places later on.
I know that this problem have been around for a vary long time, but is ther yet no solution more then temporarly remove the extensions?

MySql Connectors 6.7.4 on a medium trust shared environment

first of all, I would like to say that I have tried to resolve this issue for several hours through trying a bunch of different approaches from people that had the same issues, but to no avail. I am pretty clueless at this point.
I am using MySql.Data and MySql.Data.Entity dlls (version 6.7.4) which I have referenced in my ASP.NET 4.5 application.
I have managed to connect (locally) to my database and query it without a problem.
SqlConnection = new MySqlConnection("server=localhost;User Id=;Password=;database=;");
The problem is within a medium trust shared environment.
I get the following error (when attempting to connect to the database):
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
I have also tried to add "Integrated Security=True;includesecurityasserts=true;autoenlist=false;" to the connection string, but didn't help.
I have also tried to add this in my web.config:
<mscorlib>
<security>
<policy>
<PolicyLevel version="1">
<SecurityClasses>
<SecurityClass Name="MySqlClientPermission" Description="MySql.Data.MySqlClient.MySqlClientPermission, MySql.Data, Version=6.7.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
</SecurityClasses>
<NamedPermissionSets>
<PermissionSet class="NamedPermissionSet" version="1" Name="ASP.Net">
<IPermission class="MySqlClientPermission" version="1" Unrestricted="true">
</IPermission>
</PermissionSet>
</NamedPermissionSets>
</PolicyLevel>
</policy>
</security>
But that did not work either.
I have then tried to add a bunch of PermissionSets, IPermissions and what not in the web.config by following some articles, but that didn't seem to work for me.
Please note:
Setting trust level="Full" in the web.config is not an option.
The connection string that I use to connect to the database is not in my web.config, and I would like to keep it that way.
Using anything else than MySql is not an option.
Any and all help is appreciated! Thank you!
EDIT
I have changed the way I communicate with the database with an ODBC connection.
Works properly using full trust, but as soon as I change to medium trust, I get basically the same error as with MySql connectors.
Request for the permission of type 'System.Data.Odbc.OdbcPermission, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Can anyone please point me to the right direction, such as a full example on how you managed to make it work, because I can't seem to make this work using medium trust...
Thanks!
I ended up using an ODBC connection.
Driver={MySQL ODBC 5.1 Driver};Server=myServerAddress;Database=myDataBase; User=myUsername;Password=myPassword;Option=3;
http://www.connectionstrings.com/mysql-connector-odbc-5-1/remote-database/
I know you tried the following solution:
Change the security from the web config to full trust.
Use the bin deployment (Copy to Local for dll property).
Change the trust level from assembly.
and so many other but no one is working.
you can not deploy this on medium trust. It required full trust for proper working.
May be you are using the medium trust server for deployment. You need full trust for the deployment. Only solution is you need to run it on Full trust environment. You need to contact with your server support and change the trust level medium to Full.
Here is how I solved a similar issue with trying to get MySql to work in a medium trust environment.
We tried everything to the ‘book’ and simply could not get it to work!
Turns out the MySql connecter version is the key. Ask you web hosting company what version of the MySqlClient they have installed on their server in GAC.
(GAC simply means the library is installed on the server so that it can be referenced directly and without you having to upload the MySql.Data.dll to your bin folder. The latest installable version is available here: http://dev.mysql.com/downloads/connector/net/).
Once the driver is installed on the server in GAC you just need to reference it in your web.config like this, but replace Version=6.6.5.0 with your web hosting companies version:
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="MySql.Data, Version=6.6.5.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>
</assemblies>
</compilation>

How to access WCF RIA service from Windows Service?

I have a functioning Silverlight 4 application (VS2010, SL4, WCF RIA, hosted on my dev box using Cassini, 64-bit Windows 7). Inside the ClientBin directory I have an .svc file that describes my service:
<% #ServiceHost Service="MyApp.Services.MyService
Factory="System.ServiceModel.DomainServices.Hosting.DomainServiceHostFactory" %>
When I browse to http://localhost:52878/ClientBin/MyApp-Services-MyService.svc I see the following:
You have created a service. To test
this service, you will need to create
a client and use it to call the
service. You can do this using the
svcutil.exe tool from the command line
with the following syntax:
svcutil.exe http://localhost:52878/ClientBin/MyApp-Services-MyService.svc?wsdl
I want to access that service from a Windows Service application. My understanding is that I need to enable SOAP end-points in order to make this happen. So, I add the following to my web.config file:
<domainServices>
<endpoints>
<add name="soap"
type="System.ServiceModel.DomainServices.Hosting.SoapXmlEndpointFactory,
System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</endpoints>
</domainServices>
Firstly, Intellisense complains about the presence of the tag, saying:
The element system.ServiceModel has
invalid child element domainServices.
Secondly, the aforementioned Silverlight application stops working, presumably because this change breaks the underlying web services.
Thirdly, it appears that the System.ServiceModel.DomainServices.Hosting assembly doesn't actually contain the SoapXmlEndpointFactory type; if I try to browse to the service after adding the above to web.config I see:
Could not load type
'System.ServiceModel.DomainServices.Hosting.SoapXmlEndpointFactory'
from assembly
'System.ServiceModel.DomainServices.Hosting,
Version=4.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'.
If I inspect the assembly using Reflector, I see that it contains the DomainServiceEndpointFactory and PoxBinaryEndpointFactory types, but no SoapXmlEndpointFactory.
Could someone please let me know how I should be doing this? I can't believe that it should be this hard to simply consume a WCF RIA service in something other than a Silverlight application!
Instead of ...
System.ServiceModel.DomainServices.Hosting
use the assembly ...
Microsoft.ServiceModel.DomainServices.Hosting
from the WCF RIA Services toolkit. It contains the type SoapXmlEndpointFactory.
The default location is ... %Program Files%\Microsoft SDKs\RIA Services\v1.0\Toolkit\Libraries\Server
Have you tried just executing
svcutil.exe
http://localhost:52878/ClientBin/MyApp-Services-MyService.svc?wsdl
Alternatively, have you installed the RIA Services toolkit?
http://www.microsoft.com/downloads/details.aspx?FamilyID=7b43bab5-a8ff-40ed-9c84-11abb9cda559&displaylang=en
It's required for SOAP and JSON endpoints
The SoapXmlEndpointFactory class is part of the
Microsoft.ServiceModel.DomainServices.Hosting
assembly, which is included in the Silverlight Toolkit.
See here
<sectionGroup name="system.serviceModel">
<section name="domainServices" type="System.ServiceModel.DomainServices.Hosting.DomainServicesSection, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" allowDefinition="MachineToApplication" requirePermission="false" />
</sectionGroup>
Declare this in the ConfigSections. It's important to include the sectionGroup correctly

Categories