|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Returning an Enum From A Remote Service?I have a C# client and a C# remote service. I want to return an enum from the
service to the client. I have defined the enum in a shared DLL referenced by both client and server which also contains the shared interface. But when the code runs (on .Net 2 on XP anyway), it fails with an exception "return argument has an invalid type". If I return an int, no problem. Seems like this should work. Any pointers? Thanks. Hi David,
I haven't really tried this but is your enum serializable?... [Serializable] Just maybe. Show quote "David White" <whitedav***@comcast.net> wrote in message news:OLBGAlPVGHA.2360@TK2MSFTNGP09.phx.gbl... >I have a C# client and a C# remote service. I want to return an enum from >the service to the client. I have defined the enum in a shared DLL >referenced by both client and server which also contains the shared >interface. But when the code runs (on .Net 2 on XP anyway), it fails with >an exception "return argument has an invalid type". If I return an int, no >problem. Seems like this should work. Any pointers? Thanks. Thanks for the idea. I figured this would not be needed as the enum is
implemented via an integer type. In the docs it says that if serialization is a problem a specific, serialization-related exception should be thrown. I don't get that. Anyhow, I tried marking the enum with [Serializable], rebuilt, and tried again on your hunch. No change. But thanks. Lancelot@community.nospam wrote: Show quote > Hi David, > I haven't really tried this but is your enum serializable?... > [Serializable] > > Just maybe. > > > "David White" <whitedav***@comcast.net> wrote in message > news:OLBGAlPVGHA.2360@TK2MSFTNGP09.phx.gbl... > >>I have a C# client and a C# remote service. I want to return an enum from >>the service to the client. I have defined the enum in a shared DLL >>referenced by both client and server which also contains the shared >>interface. But when the code runs (on .Net 2 on XP anyway), it fails with >>an exception "return argument has an invalid type". If I return an int, no >>problem. Seems like this should work. Any pointers? Thanks. > > > BTW - I also found examples of Serializable annotations in the form
[Serializable()] I am not sure there is any difference between this and [Serializable] (no parens). Both compile without complaint. Neither makes any difference in my problem. I decided to also try passing the enum into a remote function. I get an error which reads something like, "due to access security..." and it fails. So I am really confused now. Any ideas? David White wrote: Show quote > Thanks for the idea. I figured this would not be needed as the enum is > implemented via an integer type. In the docs it says that if > serialization is a problem a specific, serialization-related exception > should be thrown. I don't get that. Anyhow, I tried marking the enum > with [Serializable], rebuilt, and tried again on your hunch. No change. > But thanks. > > Lancelot@community.nospam wrote: > >> Hi David, >> I haven't really tried this but is your enum serializable?... >> [Serializable] >> >> Just maybe. >> >> >> "David White" <whitedav***@comcast.net> wrote in message >> news:OLBGAlPVGHA.2360@TK2MSFTNGP09.phx.gbl... >> >>> I have a C# client and a C# remote service. I want to return an enum >>> from the service to the client. I have defined the enum in a shared >>> DLL referenced by both client and server which also contains the >>> shared interface. But when the code runs (on .Net 2 on XP anyway), it >>> fails with an exception "return argument has an invalid type". If I >>> return an int, no problem. Seems like this should work. Any pointers? >>> Thanks. >> >> >> >> David White <whitedav***@comcast.net> wrote in
news:ObSeMzyVGHA.4664@TK2MSFTNGP10.phx.gbl: You shouldn't have any problems passing enums thru remoting. Can you post > I decided to also try passing the enum into a remote function. I get > an error which reads something like, "due to access security..." and > it fails. So I am really confused now. a small and complete program that demonstrates the issue, as per Jon Skeet's typical directives? (See http://www.yoda.arachsys.com/csharp/complete.html) -mdb Michael,
Thanks for pushing me to do this obvious task. In my simple example, all works just fine as you suggest. I am still trying to make if more like my "real" program and I hope to eventually figure this out. David Michael Bray wrote: Show quote > David White <whitedav***@comcast.net> wrote in > news:ObSeMzyVGHA.4664@TK2MSFTNGP10.phx.gbl: > > >>I decided to also try passing the enum into a remote function. I get >>an error which reads something like, "due to access security..." and >>it fails. So I am really confused now. > > > You shouldn't have any problems passing enums thru remoting. Can you post > a small and complete program that demonstrates the issue, as per Jon > Skeet's typical directives? > > (See http://www.yoda.arachsys.com/csharp/complete.html) > > -mdb |
|||||||||||||||||||||||