.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How to trace to the event log from a WCF Service hosted in a Window Service.

Posted By:      Posted Date: October 22, 2010    Points: 0   Category :WCF


I have a C#.NET Windows service that I use to host my WCF service. The Windows service basically does nothing but trace some event messages to the event log and host the WCF using ServiceHost.

Is there a way to have my WCF service also trace to the event log? How do I pass parameters to my hosted WCF service? Can I pass parameters? Do I need to use a service contract instead?

 I am new to WCF and WF so let me know if I'm missing something stupid here.



View Complete Post

More Related Resource Links

problem in consuming WCF service through Window application


I have a silverlight application and WCF service all made in VS 2010 , i had hosted my site to web server which contain Window 2008 and IIS 7.0

now the problem is i have another application which is a window application developed in VS2008 , when i try to add the service reference it gives me error


The document at the url was not recognized as a known document type.

The error message from each known type may help you fix the problem:

- Report from 'DISCO Document' is 'There was an error downloading 'http://dev_qa.emspa.com/HRDev3/Service.svc?disco'.'.

  - The request failed with HTTP status 400: Bad Request.

- Report from 'WSDL Document' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.

- Report from '' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.

- Report from 'XML Schema' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.

Metadata contains a reference that cannot be resolved: ''.

Content Type application/soap+xml; charset

Team System: Team Foundation Server Event Service


Use the Team Foundation Server EventService to create and manage event subscriptions or create a Web service to receive and process events.

Brian A. Randell

MSDN Magazine May 2008

Getting AppDomain.UnhandledException event to work in a Windows Service

Nearly every forum thread I have found on "catching unhandled exceptions in a service" seems to end up where I am.  The supposed solution is the use of the AppDomain.CurrentDomain.UnhandledException event.  But it doesn't work for someone, who then asks why and gets no answer.  Same for me; I can't get the event to happen.  It's as if I need the ServiceProcess version of Application.SetUnhandledExceptionMode(), which doesn't exist. For diagnosing this, I start a timer in a child object of the service and then throw an exception in the timer event handler.  Simple enough to simulate the real situation.  I have tried subscribing to the UnhandledException event in at least a half dozen locations throughout the service, from the Program that runs ServiceBase.Run() to the constructor of the object that owns the Timer, but it never catches this exception. The VS debugger recognizes that the forced exception is unhandled and takes me to the place where is thrown, letting me know it is an unhandled exception. Why doesn't my handler catch it?  Running without the debugger, the exception throws, the timer thread crashes, the service continues merrily along, and nothing gets logged anywhere.  That is NOT the result I need.  What are the people for whom this works doing that I am not doing? How can I at least get the offe

Cannot get service reference for Net.tcp service hosted in IIS7

HiI've got a service that I want to host in IIS7. The service runs over net.tcp (currently without security), but I am unable to create a service reference to it, or call it, using the net.tcp protocol. My event log is populated with lots of errors related to ASP.NET and System.ServiceModel, relevant services are installed and running (net.tcp port sharing service and net.tcp listener adapter).O/S : Window7 RTMDevStudio: 2008I publish the webservice to IIS7 and I get a valid page when navigating to the published .svc file (which tells me to use svtutil.exe and point it at the net.tcp endpoint).For that, I get this error :    The message could not be dispatched because the service at the endpoint address 'net.tcp://gedm-desktop.profiledc01.appdevelop.local/ManageAVMEP/ManageAVMAgent.svc/mex' is unavailable for the protocol of the address.Googling the problem leads me down several blind alleys :(I cannot determine what is causing the net.tcp listener to keep stopping? Everything is fine if I use the wsHttpBinding.Any tips or pointers to a course of action would be appreciated.ThanksGed My event log is full of errors (here is a sample) :-------An error occurred while trying to listen for the URL '/LM/W3SVC/1/ROOT/ManageAVMEP'. This worker process will be terminated. Sender Information: net.tcp Exception: System.ServiceModel.WasHos

Question about WCF Service hosted in Windows Service

Hi, I have little experience with WCF and working on a projet that requires WCF Service instance to run 24x7. After searching for a solution and reading about WCF, I think if I host it under Windows Service I can have a single instance of WCF Service running 24x7. Is this correct? I just successfully ran the MSDN sample project that hosts CalculatorService in Windows Service. I realized that Windows Service cannot communicate with WCF Service it is hosting (I do not have any experience with writing Windows Service). I wrote a test function (public) in Windows Service and tried to call it from WCF Service but it did not appear in the Intellisense list. Is my assumption correct or is there a way to establish communication between Windows Service and its hosted WCF Service? Thanks. kr

Duplex communication and calling clients from outside the hosted service

Hey,   I am currently building an interface between two applications: One that hosts a WCF service and receives external input (e.g. from a sensory system) and another which subscribes to updates sent by the first.   It is quite easy to call back to the client if I create a ServiceHost and provide it with an instance of my service (using ServiceHost.SingletonInstance). However, if I use a PerSession instance mode, how is it possible to call the clients when I receive an updated from the external sensory system?   Thank you for your time!   Cheers, Till

FIMSynchronizationService can not start (event id:6324) and The Forefront Identity Manager Service c

Hi, I have this two issuses 2 days. I tried lots of ways, I can not fixed it. I have fully permission accunt to create User Proflie Sych. Even last week, everything is fine, but since I deployed the Sql2005 maintenance for our database. It shows those two issues. Please help!

WCF Service hosted in IIS 6 failing on idle timeout and does not restart

I've got a WCF service hosted in IIS 6 with its own application pool.  The application pool is running under a domain service account.  It appears that the application pool's idle shutdown setting is killing WCF service and subsequent requests to the WCF service get an exception as listed below I can only access after I browse to the .svc page in order to get it working again.   I've went through the svc tracing and able to see where the ServiceHost closes down. I have tried various session management techniques with no result. I haven't read anything about having to disable the idle timeout in IIS 6 when hosting a WCF service, and I suspect that there shouldn't be any need to.   Can anyone provide any insight into why this is happening?   ******************* My client exception ******************* Test method **********  threw exception:  System.ServiceModel.ProtocolException: The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '<html>     <head>         <title>Runtime Error</title>      

I have dual core machine i have hosted wcf service . At a time how many requests my server will exec

I have dual core machine i have hosted wcf service . At a time how many requests my server will execute how to find that count.

Problem with hosting wcf service using window service in window 7

Hi all! I have a wcf service, I hosted susessfuly in winxp, but in window 7, it throw an excaption like that Message="HTTP could not register URL http://+:8000/EchoService/. Your process does       not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details). After that, I tried to run the  following command on window 7  to configure HTTP:             netsh http add urlacl url=http://+:8000/MyUri user=DOMAIN\userid I get error  Then, I run as Administrator and execute the above command, I get an error like here Create SDDL failed, Error: xxx The parameter is incorrect. I dont know why, and  how to fix the problem. Please help me!   Thanks all.    

How to measure WCF start up time ? ( WCF service .NET 3.5 hosted in IIS6 under win 2003 )

Hi ,   I have relative big and complex WCF (.net 3.5)service hosted in IIS 6 .  When IIS worker goes down , it takes a lot of time for service to wake up.  My question is how can I measure what exactly takes time ? Or its just service compilation time and nothing could be done here ? If I know what takes time I will try to optimize it .    Thanks. 

Not able to generate proxy for the service hosted on IIS, but working on Dev Web Server?

Hi, I have tried to host WCF on the IIS, it browsed sucessfully using the path http://localhost/WCF/Service1.svc but when tried to generate proxy using SvcUtil, it generated the following message. Bus the same when tried from the development server is working file. c:\Program Files\Microsoft Visual Studio 9.0\VC>svcutil.exe http://localhost/WCF /Service1.svc?wsdl Microsoft (R) Service Model Metadata Tool [Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.2152] Copyright (c) Microsoft Corporation.  All rights reserved. Attempting to download metadata from 'http://localhost/WCF/Service1.svc?wsdl' us ing WS-Metadata Exchange or DISCO. Microsoft (R) Service Model Metadata Tool [Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.2152] Copyright (c) Microsoft Corporation.  All rights reserved. Error: Cannot obtain Metadata from http://localhost/WCF/Service1.svc?wsdl If this is a Windows (R) Communication Foundation service to which you have acce ss, please check that you have enabled metadata publishing at the specified addr ess.  For help enabling metadata publishing, please refer to the MSDN documentat ion at http://go.microsoft.com/fwlink/?LinkId=65455. WS-Metadata Exchange Error     URI: http://localhost/WCF/Service1.svc?wsdl     Metadata contains a reference that cannot be resolved: 'http:

Send/open timeouts on WAS-hosted WCF service with named pipe orTCP binding, per-call instancing

We have a client that sends requests to a per-call WCF service (WAS hosted, NP binding, same machine) in a loop. The WCF service calls an external EXE to process requests. The operations on the service can take a few seconds, or a few hours. To combat this, we have sendTimeout=00:05:00, receiveTimeout=00:05:00 and a built-in circuit-breaker on the service that kills the external process after 00:05:00. Any service-side errors are returned to the client as FaultExceptions.  On the client, FaultExceptions are logged and the client proxy is aborted (proxy.Abort()). The client has configurable multithreading. In this example, it is running 3 threads, each of which creates a proxy, makes a call, and closes the proxy (or aborts it if an exception was received). Since the service is instanced as per-call, and it never receives more than 3 simultaneous calls (each of which being followed by a .Close() or .Abort() on the proxy), I would not expect the client to be getting timeouts during the send, but I am. In fact, the send timeouts I am receiving would seem to imply that the WCF service is hitting the default session limit, even though the class is explicitly marked with [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]. I put some trace logging on the client and I can see that the timeout is occurring when the proxy is being created. sendTimeout seems to

Launch window forms app from windows service

I have a windows forms app that is used to manage settings for a windows service. When the service starts I want to launch the forms app. I'm using Process.Start("myWindowsApp") and I can see the app running in the task manager processes but the windows aren't displayed. My guess is that it's because the service is running under the localsystem account but what do I need to do to make the windows forms app work properly? SteveR

The request failed or the service did not respond in a timely fashion. Consult the event log or othe



           Actually i have installed SQL Server 2008 R2 on XP Pro SP3 it works fine after instaling first time but when i restarted my pc SQL Server Service didn't restarted and so i tried to restart that manuly by clicking start in Sql Server Configuration Manager at that it gave this error "The request failed or the service did not respond in a timely fashion. Consult the event log or other application error logs for details."


I tried to repair it again but it doesent resolved .So i Uninstalled it SQL Server 2008 R2 and all its shared tools and installed it again but nothing changed it again gave me the same problem as in 1st instalation after restating maching.

      Any idea! Where i am going wrong?.

i got this thing in Event log of Application

Event 1

"FCB::RemoveAlternateStreamsByHandle(BackupSeek): Operating system error (null) occurred while creating or opening file 'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\transport.mdf'. Diagnose and correct the operating system error, and retry the operation."

Event 2


WCF Window Service Hosting



now i am developing wcf services those will host on window service .In my project,there are several wcf services,                                                                          for example,CustomerService,SupplierService,SaleService,PurchaseService and TransferService.How i host those services on window service?                                 Will Each service acts as distinct window service?so,i have 20 services,are there 20 services in window service?After hosting,if i change some methods of  one service,do i need to uninstall all service?Please guide me and help me.I m not familiar with wcf configuration.sorry for poor of my english.



WCF hosted in a Windows Service, how to make calls to the WCF service from within the service host


I have a Windows service that I converted to a WCF service that I want to host in a Windows Service.  I need to do some specific tasks in the OnStart() and OnStop() just like I did when it was just a Windows service.  My original Windows service OnStart() is where I create the main worker thread.  So how do I make a call into my WCF service from within the hosting service? For example in the hosting service's OnStart() I do a host.Open() then I need to call a method in my WCF service but how?



ServiceHost host =

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend