Failed to activate using the NETTCPBINDING,WCF service

Source: Internet
Author: User

My WCF uses the nettcpbinding, the use will be an error, change to BasicHttpBinding, everything is normal

The requested service, ' net.tcp://wcf.xxxxx.com:21336/gameservice.svc ' could not being activated. See the server's diagnostic trace logs for more information.

Then I use the browser to access the SVC, the client requests it again, but not access every few minutes, the error appears

=====================================================================

This problem bothers me for a lot of days, online is also looking for no solution (now want to actually think about the wrong direction, thinking that the configuration has a problem, is actually a WCF service Dependency injection initialization problem)

The key moment still depends on the StackOverflow, a random search to find a solution

AUTOFAC WCFINTEGRATION-WCF Client Service can is activated when communicating over net.tcp

So I used the AUTOFAC.INTEGRATION.WCF to do the dependency injection of the WCF service.

<%@ ServiceHost language="C #" debug="true"      Service="Wettery.WcfContract.Services.IGameService, Wettery.WcfContract.Services"      Factory="Autofac.Integration.Wcf.AutofacServiceHostFactory, AUTOFAC.INTEGRATION.WCF" %>

Initialization of dependencies is done in Global.asax's Application_Start

But Global only applies Http bindings, and TCP bindings can take another approach:

Create a class under App_Code, add a static method public static void AppInitialize (), and this method will be executed automatically when the service starts

Note: Classes containing appinitialize static methods can only be placed under App_Code, and this method must be unique

For more detailed reference:

When AppInitialize method get invoked in ASP?

Failed to activate using the NETTCPBINDING,WCF service

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.