List Info

Thread: Re: Remoting and Windows messages (e.g., PlugNPlay message)




Re: Remoting and Windows messages (e.g., PlugNPlay message)
user name
2008-02-24 00:51:00
Thanks for the reply. Sorry if this is the wrong forum. I
saw
"DotNetDevelopment" and ".NET Remoting"
and thought this was the right
place. If there's somewhere more appropriate (that isn't
dead, of
course), please let me know. If worst comes to worst, I can
re-work it
in C#, but I don't think the problem is C++-specific. (I
used C++
because that's what my real project's code is in.)

My understanding, which could be flawed, is that on Windows,
when such
a PnP event occurs, a Windows message is broadcast to all
apps.
Indeed, if I make a CLR or standard C++ console app, which
by default
has no message pump, I get the same effect as with Remoting
-- namely,
no callback -- whereas if I make a simple MFC or WinForms
app, which
does have a message pump, I get the callback. The difference
seems
tied to Remoting somehow.

If my understanding of how the PnP messaging works is
correct, then
the client and server, each of which have a WinForms GUI and
hence a
message pump, should get the PnP message independently and
handle it
appropriately. I have not, however, determined if either the
client or
server receives such a Windows message, though I presume
that at least
the server has not received it since I see no callback. How
can I
check for sure? Is it possible that the client is receiving
the
message but the server isn't *because* they are connected
via Remoting
(seems strange since they're separate processes that are
started
independently)?

What "remoting configuration" information are you
looking for?

Cheers! --M

PS, Sorry if this shows up twice. Google is giving me
problems
tonight.

On Feb 23, 9:37 am, "Andrew Badera" <and...badera.us> wrote:
> You say the problem comes when you introduce remoting,
but then you say your
> app apparently never gets any events. You'll need to be
a little clearer for
> us dumb non C++ folks (this is a C#/VB forum,
syntactically speaking) are
> you saying the client never fires an event, or your
remoting server never
> seems to be catching any events? if the latter, what's
your remoting
> configuration look like, on both ends?
>
> On 2/22/08, mlimber <mlim...gmail.com> wrote:
>
>
>
>
>
> > Hi,
>
> > I have a third-party DLL over which I have no
control. I supply it a
> > delegate/callback function to be invoked when some
event occurs (in my
> > case, a USB device is added to or removed from the
system). I have
> > several applications that use this DLL and its
event processing
> > successfully, including an MFC app and a WinForms
app.
>
> > The problem comes in when I introduce .NET
Remoting. I've reduced the
> > code a bit for simplicity, but here is the class
that I export:
>
> >   /////////////////////////////////////////
> >   // Remoting Library.h
> >   /////////////////////////////////////////
>
> >   #include "../USBTargetImpl.cpp"
>
> >   namespace RemotingLibrary
> >   {
> >     public ref class SampleObject : public
System::MarshalByRefObject
> >     {
> >     public:
> >         SampleObject();
> >         System::Boolean m_isDevicePresent;
> >     private:
> >         USBTargetImpl^  m_usb;
> >     };
> >   }
>
> >   /////////////////////////////////////////
> >   // Remoting Library.cpp
> >   /////////////////////////////////////////
>
> >   #include "Remoting Library.h"
> >   #include <vcclr.h>
>
> >   namespace
> >   {
> >     gcroot<RemotingLibrary::SampleObject^>
s_sampleObject;
>
> >     void USBCallback( const bool isDevicePresent
)
> >     {
> >         if( s_sampleObject )
> >         {
> >             s_sampleObject->m_isDevicePresent =
isDevicePresent;
> >         }
> >     }
> >   }
>
> >   RemotingLibrary::SampleObject::SampleObject()
> >     : m_usb( gcnew USBTargetImpl( &USBCallback
) )
> >     , m_isDevicePresent( true )
> >   {
> >     s_sampleObject = this;
> >   }
>
> >   //////////////////////////////////////////////
>
> > As you can see, I supply a callback to a member in
the constructor to
> > RemotingLibrary::SampleObject. The code for
USBTargetImpl is not
> > important for our purposes here, but I can post it
if you think you
> > need to see it (it registers its own internal
callback with the third-
> > party DLL and, on add/remove events, calls back
the function supplied
> > to the constructor when its callback gets
invoked).
>
> > My server and client code for this simplified
example are converted to
> > Managed C++ and adapted from <http://www.develo
per.com/net/cplus/
> > article.php/1479761>. In particular I made the
client and server
> > WinForms apps rather than console apps (but the
console apps don't
> > work either, presumably since there is no message
pump). The client
> > just polls the m_isDevicePresent variable every
half-second or so.
>
> > The problem is, my app apparently never gets any
add/remove events and
> > hence the callback is never invoked. My
supposition is that the
> > Windows message for PlugNPlay is not being handled
in a normal way in
> > the server because of Remoting.
>
> > Any thoughts on how to handle this better?
>
> > Thanks in advance! --M
>
> --
> --Andy Baderahttp://andrew.badera.us/

> and...badera.us
> (518) 641-1280
> Google me:http://w
ww.google.com/search?q=andrew+badera

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "DotNetDevelopment, VB.NET, C# .NET,
ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting"
group.
To post to this group, send email to DotNetDevelopmentgooglegroups.com
To unsubscribe from this group, send email to
DotNetDevelopment-unsubscribegooglegroups.com
For more options, visit this group at
http:
//cm.megasolutions.net/forums/default.aspx
-~----------~----~----~----~------~----~------~--~---


Re: Remoting and Windows messages (e.g., PlugNPlay message)
user name
2008-02-24 08:07:13
Not a biiiig deal on the C++, it's just that I can probably better understand the specifics of your situation if we're talking C#. When it comes to C++, I'm a hack.

Remoting channels need to be configured, either through app.config or through programmatic use of ChannelServices, as page two of that article shows. So, what's the configuration you're using? Channel, port, serialization type, etc. etc. for both server and client side. How exactly are you hosting the remoting service, and how are you starting and connecting to it?

But, I think I better understand your situation now. You're trying to catch a PnP event client-side, using a remoted object, and notify the remoting service, right?

I believe you're correct, remoting clients don't tap into the message pump. I believe only WinForms apps do that by default, and I'm not sure if you can enable that in a service or console.


On 2/24/08, mlimber < mlimbergmail.com">mlimbergmail.com> wrote:

Thanks for the reply. Sorry if this is the wrong forum. I saw
"DotNetDevelopment" and ".NET Remoting&quot; and thought this was the right
place. If there's somewhere more appropriate (that isn't dead, of
course), please let me know. If worst comes to worst, I can re-work it
in C#, but I don't think the problem is C++-specific. (I used C++
because that's what my real project9;s code is in.)

My understanding, which could be flawed, is that on Windows, when such
a PnP event occurs, a Windows message is broadcast to all apps.
Indeed, if I make a CLR or standard C++ console app, which by default
has no message pump, I get the same effect as with Remoting -- namely,
no callback -- whereas if I make a simple MFC or WinForms app, which
does have a message pump, I get the callback. The difference seems
tied to Remoting somehow.

If my understanding of how the PnP messaging works is correct, then
the client and server, each of which have a WinForms GUI and hence a
message pump, should get the PnP message independently and handle it
appropriately. I have not, however, determined if either the client or
server receives such a Windows message, though I presume that at least
the server has not received it since I see no callback. How can I
check for sure? Is it possible that the client is receiving the
message but the server isn't *because* they are connected via Remoting
(seems strange since they're separate processes that are started
independently)?

What "remoting configuration" information are you looking for?

Cheers! --M


PS, Sorry if this shows up twice. Google is giving me problems
tonight.


On Feb 23, 9:37 am, "Andrew Badera&quot; < and...badera.us">and...badera.us> wrote:

> You say the problem comes when you introduce remoting, but then you say your
> app apparently never gets any events. You'll need to be a little clearer for
> us dumb non C++ folks (this is a C#/VB forum, syntactically speaking) are
> you saying the client never fires an event, or your remoting server never
> seems to be catching any events? if the latter, what's your remoting
> configuration look like, on both ends?
>

> On 2/22/08, mlimber < mlim...gmail.com">mlim...gmail.com> wrote:
>
>
>
>
>
> > Hi,
>
> > I have a third-party DLL over which I have no control. I supply it a
> > delegate/callback function to be invoked when some event occurs (in my
> > case, a USB device is added to or removed from the system). I have
> > several applications that use this DLL and its event processing
> > successfully, including an MFC app and a WinForms app.
>
> > The problem comes in when I introduce .NET Remoting. I've reduced the
> > code a bit for simplicity, but here is the class that I export:
>
> >   /////////////////////////////////////////
> >   // Remoting Library.h
> >   /////////////////////////////////////////
>
> >   #include "../USBTargetImpl.cpp"
>
> >   namespace RemotingLibrary
> >   {
> >   ;  public ref class SampleObject : public System::MarshalByRefObject
> >   ;  {
> >   ;  public:
> >   ; &nbsp; &nbsp;  SampleObject();
> >   ; &nbsp; &nbsp;  System::Boolean m_isDevicePresent;
> >   ;  private:
> >   ; &nbsp; &nbsp;  USBTargetImpl^ &nbsp;m_usb;
> >   ;  };
> >   }
>
> >   /////////////////////////////////////////
> >   // Remoting Library.cpp
> >   /////////////////////////////////////////
>
> >   #include "Remoting Library.h&quot;
> >   #include <vcclr.h>
>
> >   namespace
> >   {
> >   ;  gcroot<RemotingLibrary::SampleObject^>; s_sampleObject;
>
> >   ;  void USBCallback( const bool isDevicePresent )
> >   ;  {
> >   ; &nbsp; &nbsp;  if( s_sampleObject )
> >   ; &nbsp; &nbsp;  {
> >   ; &nbsp; &nbsp; &nbsp; &nbsp;  s_sampleObject->m_isDevicePresent = isDevicePresent;
> >   ; &nbsp; &nbsp;  }
> >   ;  }
> >   }
>
> >   RemotingLibrary::SampleObject::SampleObject()
> >   ;  : m_usb( gcnew USBTargetImpl( &USBCallback ) )
> >   ;  , m_isDevicePresent( true )
> >   {
> >   ;  s_sampleObject = this;
> >   }
>
> >   //////////////////////////////////////////////
>
> > As you can see, I supply a callback to a member in the constructor to
> > RemotingLibrary::SampleObject. The code for USBTargetImpl is not
> > important for our purposes here, but I can post it if you think you
> > need to see it (it registers its own internal callback with the third-
> > party DLL and, on add/remove events, calls back the function supplied
> > to the constructor when its callback gets invoked).
>
> > My server and client code for this simplified example are converted to
> > Managed C++ and adapted from <http://www.developer.com/net/cplus/
> > article.php/1479761&gt;. In particular I made the client and server
> > WinForms apps rather than console apps (but the console apps don't
> > work either, presumably since there is no message pump). The client
> > just polls the m_isDevicePresent variable every half-second or so.
>
> > The problem is, my app apparently never gets any add/remove events and
> > hence the callback is never invoked. My supposition is that the
> > Windows message for PlugNPlay is not being handled in a normal way in
> > the server because of Remoting.
>
> > Any thoughts on how to handle this better?
>
> > Thanks in advance! --M
>
> --

> --Andy Baderahttp://andrew.badera.us/

> and...badera.us">and...badera.us

> (518) 641-1280
> Google me:http://www.google.com/search?q=andrew+badera





--
--Andy Badera
http://andrew.badera.us/
andrewbadera.us">andrewbadera.us
(518) 641-1280
Google me: http://www.google.com/search?q=andrew+badera
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting&quot; group.
To post to this group, send email to DotNetDevelopmentgooglegroups.com
To unsubscribe from this group, send email to DotNetDevelopment-unsubscribegooglegroups.com
For more options, visit this group at
http://cm.megasolutions.net/forums/default.aspx
-~----------~----~----~----~------~----~------~--~---

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )