Can anyone offer a reasonable explanation as to why exactly I need to use wclShowError in this way? I need to place these functions into an architecture, and having some hidden code that could potentially open dialog boxes simply won't work. What can I do to correct the behavior, or what have I missed???

Most of WCL methods return error code as an operation result. wclShowError just takes this result (error code) and if it is not WCL_E_SUCCESS (0) shows a error message (and returns true). If error code is WCL_E_SUCCESS then wclShowError does not show any message (and returns false).

So in your code without wclShowError you have to analize Write operation result somehow by other way. Unfortunately without result of operation (error code) I can not say what can be wrong there.

spavetti

No! That's not what's happening! The ONLY changes in my app are the ones listed in my OP. Again. If I don't use the wclShowError, then the application fails to send. My client device also indicates a successful connection.

Unfortunately it is impossible. The only case when WCL_E_NOT_CONNECTED returned is when wclClient it not connected. So I am sure that Client is not connected (you can check it by simple checking its State property, it must be csConnected). When do you call Write method?

spavetti

I can say with certainty that this is what's I'm experiencing. I'm sure there's a perfectly reasonable explanation for what's going on. Is it possible that there's a library conflict? I'm using .NET 4.0 libs, and my application is also targeted for .NET 4.0. The sample seems to operate as expected, although I haven't tried to alter it by removing the wclShowError.

I've been struggling to explain the behavior for days. I'll note that the event for connection is never getting triggered for any of the original code I posted. I never seem to get out of the Connecting state, even though it gets called back on the client demo - and I'm using that same code (with minor alterations - nothing stupid like not performing connection, give me some credit) in a relatively unaltered state. The client device is an android tablet that does a simple echo function. Eventually the events for data available are triggered as well. I'm wondering why it would work at all for ANY of the code I posted if I couldn't get out of the connecting state? And why does the magic of wclShowError create some weird success when there shouldn't be then?

Here are the steps I took:1) Take the ClientDemo form2) Turn the form class into an ordinary class - removing the derivation from Form3) Remove all extraneous events for discovery4) Change other trivial details such as changing the constructor to inject parameters - none are wcl classes, they're all primitives5) Instantiate and try to use....

spavetti

I did some more tests, and what I found was that I could get my code to operate in a winforms app, and not a console app. I provided a solution with 2 projects that use identical code that was derived from the clientdemo. Can you provide some insights on why there is a difference, or what my issue is?

WCL requires a message loop to work as some stacks and low-level drivers send its events by using Windows Messages (as it was already explained on this forum lot of times). Take a look on service demo to find out how to use WCL in non WinForm application (in application which does not have a default message loop).