I have WCF service hosted in console app. Service tries to connect to opened windows application via DDE protocol. No luck. Where is the problem? Console app is running in my account, as the dde windows app.
I'm not expert in this field, but I believe DDE requires that you have a running message pump (which a console application lacks), so you may have better luck hosting your WCF service in a WinForms app.
You have provided so little details about the problem that is going to be nearly impossible to give you a definitive answer. However, your comment to Allon's answer is interesting.
If i run listener in console without
WCF, all is fine
So your DDE application is listening for something? I now have to assume that you have attempted to create a DDE client that subscribes to an advisory loop via DdeClient.StartAdvise. This method of data retrieval is highly dependent on a message pumping mechanism.
When you create an instance of DdeClient it will by default create its own message pump on a separate thread to receive these advisory notifications. That would explain why it works when you leave your code in a basic console application.
However, when you mix WCF there may be some adding complexities particularly concerning threads that may have to be dealt with manually. The only way I am going to be able to tell is if you provide more information.
Related
For a few weeks now I've been having a really weird problem. I have a couple of services which work just fine when self-hosted in a command line app. However in IIS+AppFabric I cannot access one of the services - I get TimeoutException and am pretty sure that the call doesn't even make it to the service (all services have an aspect to log all calls before doing anything). Note that both services are configured identically with regards to bindings and behaviors by code. I tried many things like putting them on different app pools, disabling some of the transports... And what is really strange that if both services are in one app pool - one of the services works but if I put them on separate threads - the other service times-out. It really drives me nuts...
Also I see pretty often events in the system event log: "A process serving application pool 'Authorization Management' suffered a fatal communication error with the Windows Process Activation Service. The process id was '11852'. The data field contains the error number." The error number is 0x80070218. After the event the service host initializes without problems (I can see my own info log messages) however the service is unreachable.
Does this ring a bell to anyone?
Thanks!
It turned out that I had a bug in the initialization of the services' hosts. I was trying something, and when I removed the try code, apparently I didn't delete the first line which was locking some resource.
Anyway, it is a good lesson. Nevertheless, if your services do not work, your initialization might be buggy...
Sorry about the noice.
I need to create a Windows Service to watch a folder on our network and action files that are placed within it. The process is quite slow and I need the ability to check the progress from a client application (which will be running in about 10 places on the same network as the machine running the Windows service).
Is hosting some WCF service in the windows service the right way to go about this and if so, are there any resources on how I would do this?
Thanks!
it seems a reasonable approach to me.
you can get details of how to host a WCF service inside a windows service in the MSDN how to
This code project page also has an example.
you might need to debug start up issues with the service, and I find adding a
Debugger.Launch();
to the beginning of the OnStart method is the easiest way of doing that. it enables you to debug through the start up process of your service and see any exceptions that occur.
What is the best way to combine a single instance WCF service that uses ActiveMQ and runs within IIS/AppFabric?
Our Services need to support both HTTP transports and ActiveMQ (listening and sending messages). We've elected not to use MSMQ, and will use Spring.Net.NMS. The fundamental issue I have now is that ActiveMQ needs to connect to the queue(s) at startup and remain connected, but WAS is getting in the way with it's message-activation feature. If the service is not activated until a message arrives (HTTP/MSMQ, etc) then there is no trigger to have the connection to AMQ occur.
I know I can disable the recycling behavior, and I know I can do self-hosting with a Windows Service. But I want to take advantage of the monitoring and other features in AppFabric. I've already been down the route with IServiceBehavior and will use that for other nice things. But that interface is not called until a (non-AMQ) message arrives. So it won't work for this. What I was hoping for was something along the line of how ServletContextListeners work in Java, where you get both the start up and shutdown events. But it seems no such thing exists in WAS... it is driven only by messages arriving.
I've scoured every inch of web info for 3 days and the only thing I came across was to use a static class construction (C#) trick as the trigger. That's a hack, but i can live with it. It still leaves the issue of cleanly shutting down, which I can figure out later.
Anyone have a solid solution to this?
The direct WCF support for ActiveMQ that Ladislav mentions is still being supported. There just hasn't been an official release for the module in a while. However, you can still get the latest version of it from the 1.5.x branch or trunk and compile it yourself.
1.5.x branch for use with Apache.NMS 1.5.0:
https://svn.apache.org/repos/asf/activemq/activemq-dotnet/Apache.NMS.WCF/branches/1.5.x/
Check out instructions:
http://activemq.apache.org/nms/source.html
There was direct WCF support for ActiveMQ but I guess it is not developed anymore. Your problem actually is the IIS / WAS (provides hosting for non-http protocols) hosting architecture. Services in WAS are always activated when message arrives - there is no global startup. The reason for this is that WAS hosting expects that there is separate process (windows service) running the listener all the time and this process has adapter which calls WAS and uses message level activation. I guess you don't have such process for ActiveMQ and because of that you will have trouble to use ActiveMQ endpoint hosted in WAS. Developing such listener can be challenging task (example for UDP).
Creating custom listener can be probably avoided by using IIS 7.5 / AppFabric auto start feature. There is also not very well documented way to run the code when the application starts.
I have some very odd situation at a client that wants me to maintain some of their software:
upon start/stop, the EventLog entries of a Windows Service are correctly appearing.
But during incoming WCF calls, they are not.
All EventLog creating is going through the same global static factory class.
When I put all classes in a console app, everything logs fine.
When sending those entiries to OutputDebugString, the same happens: windows Service Startup/Shutdown are coming through fine, but WCF execution not.
Where should I start digging?
These kinds of problems are hard to figure out. I would start by attaching the debugger to the WCF service and adding some breakpoints in the logging classes and see if the code actually stops. If not move the brake point to the service and see why it doesn't get into the logging code.
Given that the code works in a console app and only partly in a WCF service my first guess is that it could be a threading issue. But without more info that is just pure speculation.
I have a server that needs to keep a small number of clients in sync. Whenever there is a change of state at the server, all the connected clients must be informed.
I am planning to use a “callback
contract”,
I can get hold of the
callback reference for each client on
the server by using
GetCallbackChanel().
I then need
to manage all these client channel
reference and call all of them when
needed.
So far so good however:
I don’t wish to block the server, so calls to the clients must be none blocking
Errors calling the client must be logged and coped with
Is there a standard WCF component to do this?
No, there is not a standard WCF component for this, at least through .NET 3.5. I can't speak to what may be available in .NET 4.0.
That said, there is a pretty straightforward way to do this. Juval Lowy, author of Programming WCF Services, describes how to do this using his WCF-based Publish-Subscribe Framework.
Basically, the idea is to create a separate WCF event service that resides in the same hosting application as your server (e.g., Windows service, IIS). When the state of your server changes, you publish the state change to the event service. The clients that need to be kept in sync subscribe to this same event via the event service. In effect, the event service becomes a broker for your server to notify clients of whatever events your server publishes.
The article I listed above has a code download, but you can also get the Publish-Subscribe Framework and a working example for free from his website, IDesign.net. Here is the link to the download. You may need to scroll your browser up just a little bit to see it as I believe their internal hyperlink is wrong.