Logging the log using NLog which uses WCF services - wcf

I want to log me error using Nlog dll which internally call the WCF services to log the error.

You may want to take a look at the LogReceiverService target. It sends log messages to a NLog Receiver Service (using WCF or Web Services).

Related

Can I run a Hosted Service in the ASP.NET Core Web Host? (getting System.ObjectDisposedException )

I have an ASP.net Core web API running the ASP.net Core Web Host.
In the ServiceCollection, I register a HostedService to run a worker that subscribes to a message bus.
Some messages come from web API. Some messages come from the message bus through the worker.
They all get written to a database.
Presently I'm having problems where when I write messages coming from the worker to the database I get System.ObjectDisposedException on my dependency injected data access Scoped service.
It feels like my worker is somehow using the HTTP request scopes for the DI injected services.
So, could this be caused by using a Hosted Service in the ASP.NET Core Web Host
Do not read messages in a ServiceHosted, you should read it seperately (maybe in a singleton scenario)
If you're reading messages from service-bus manually you should not have that problem otherwise you should not use scoped services for that. for example in RabbitMQ the best practice is to open a connection for each app

WCF in windows service hosting with silverlight application

I have written WCF and hosted in windows service now when accessing the services via basic http binding, it is showing "This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details." Please suggest solution step by step
Thanks to all for not replying but I got the solution. Please suggest if anything is not in order.
We have created WCF and hosted it in Windows Services as netTCP. Now, I created Silverlight Enabled WCF Services in Silverlight.Web Project and call netTcp service from here and Silverlight WCF enabled Services called in Silverlight Project and it is running fantastic. Before this I tried from Web Service but it is taking when large data calling from silverlight application.

Dumping data reported by client to server to a Log file

I'm using WCF services in the client application for transfering data from client to server and vice-versa. I'm looking for a mechanism to log the data sent to server into the log file on client machine. I looked into the WCF library but could not find any code which serializes the WCF requests. Logging no issues, I use N-Log for that but I don't find any built in function which gives the webrequest data.
My question is, is there any built in support for getting the webrequest details?
The built in option is called Message logging but this option uses its own way to log messages using standard .NET trace listeners.
If you want custom message logger you have to implement your own logging endpoint behavior with IClientMessageInspector.

WCF Service Method Name in IIS Log

Can the IIS logs be configured to output the name of the method called for a WCF service?
Right now the logs show only the name of the svc file.
Current log:
/myservice.svc
I would like it to show:
/myservice.svc/mymethod
Unfortunately, there is no way to have the IIS standard logging log the method name called on a service. It only registers the page serviced.
You can however enable WCF logging to produce an svclog file that does give complete insight in method invocations and WCF service operations. For details, look at: http://msdn.microsoft.com/en-us/library/ms730064.aspx.
Might that be acceptable?

Can you pass data from HttpModule to IIS hosted WCF without aspNetCompatibility enabled

I currently have a HttpModule that generates a unique ID per external client request, appends it to the IIS log, and adds it to the HttpContext.Items collection in order to pass in on the thw web service.
I am currently replacing the web service with a WCF service (still hosted under IIS). I can successfully do the same process by enabling AspNet compatibility, but I would prefer not to. Is there any way to pass data from a HttpModule to say the OperationContext of the WCF service without enabling AspNet compatibility?
This is what MSDN has to say,
HttpModule extensibility: The WCF hosting infrastructure intercepts WCF requests when the PostAuthenticateRequest event is raised and does not return processing to the ASP.NET HTTP pipeline. Modules that are coded to intercept requests at later stages of the pipeline do not intercept WCF requests.
I suggest you go through this MSDN documentation completely to understand how ASP.Net and WCF coexist