473,396 Members | 2,076 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

casting WebService TreeNode to C# Client App TN

djp
Hi
I add web reference to my C# client app and call web method that returns
TreeNode.
I tried to cast WebService TreeNode to Windows Forms TreeNode, but without
any effect.
Any ideas?

Thanks
PK
Mar 24 '07 #1
3 1538
When you utilize a web service to return an existing type, the service
framework will create a new type for its purposes; it does this because not
everything that can be found in a .Net "type" makes sense in a webservice
"type". What you are more than likely encountering is a casting issue
because the type generated by the service framework is different than the
windows forms treenode. This is a basic/fundamental issue of typing.

If you absolutely have to pass a treenode instance from a web service, you
could always use serialization and return a byte stream; I have never done
this but I can't see why it wouldn't work.

.....not sure of your ultimate goal here, though.

--
~~~~~~~~~~~
Ben Rush
http://www.ben-rush.net/blog
"djp" <pi*************@gmail.comwrote in message
news:4e***************************@news.chello.pl. ..
Hi
I add web reference to my C# client app and call web method that returns
TreeNode.
I tried to cast WebService TreeNode to Windows Forms TreeNode, but without
any effect.
Any ideas?

Thanks
PK

Mar 24 '07 #2
djp
i am not sure if sending byte stream is good idea. Concept of WebServices is
to pass objects.
When i create webservice treenode and windows.forms treenode i can see that
they are identical
iam almost sure there is a way to cast one to another, however i cannot find
solution...

When you utilize a web service to return an existing type, the service
framework will create a new type for its purposes; it does this because
not everything that can be found in a .Net "type" makes sense in a
webservice "type". What you are more than likely encountering is a casting
issue because the type generated by the service framework is different
than the windows forms treenode. This is a basic/fundamental issue of
typing.

If you absolutely have to pass a treenode instance from a web service, you
could always use serialization and return a byte stream; I have never done
this but I can't see why it wouldn't work.

....not sure of your ultimate goal here, though.

Mar 24 '07 #3
The members, methods, properties, etc. can all be identical but it can still
be a different data type as far as the runtime is concerned. How are you
seeing that they are identical? Type identity is more in-depth than
identical members. If you cannot cast one to another, then the types are
different.

You can pass anything you want back from a web service, it doesn't have to
be an object.

"djp" <pi*************@gmail.comwrote in message
news:2d***************************@news.chello.pl. ..
>i am not sure if sending byte stream is good idea. Concept of WebServices
is to pass objects.
When i create webservice treenode and windows.forms treenode i can see
that they are identical
iam almost sure there is a way to cast one to another, however i cannot
find solution...

>When you utilize a web service to return an existing type, the service
framework will create a new type for its purposes; it does this because
not everything that can be found in a .Net "type" makes sense in a
webservice "type". What you are more than likely encountering is a
casting issue because the type generated by the service framework is
different than the windows forms treenode. This is a basic/fundamental
issue of typing.

If you absolutely have to pass a treenode instance from a web service,
you could always use serialization and return a byte stream; I have never
done this but I can't see why it wouldn't work.

....not sure of your ultimate goal here, though.


Mar 24 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Andrew | last post by:
created a custom class that is derived from TreeNode, let's call it customTreeNode. I'm trying to use the TreeViewEventArgs (for the AfterSelect event) but I cannot cast to my derived TreeNode. ...
2
by: Benny Raymond | last post by:
More problems with this... When I run this code, the main form returns an invalid cast exception as it's executing the line "TreeNode n = (TreeNode) this.Nodes;" Does anyone know what would...
6
by: Davie | last post by:
I want to authorise a user of a web service by using the AuthHeaderValue for some reason I keep getting a null reference exception when I try to run the following code: It seems to work fine on a...
11
by: Andy | last post by:
Make the story short, I have a VB.NET client interface calling .NET webservice, written in VB.NET as well. I am trying to make the client as thin as possible so I let the webservice part to...
2
by: Miguel | last post by:
Hi, I'm developing an application in C# with Windows Forms for my company that is similar to the MSN Messenger. This application uses a webservice for registering users, etc... and as 2...
7
by: Nalaka | last post by:
Hi, I created a sinple web service that returns a dataSet. Then I created a client program that uses this web service (that returns the Dataset). My question is, how did the client figure...
2
by: Jim S | last post by:
I have a .net framework 2.0 client (Pocket PC) and a .net 2.0 webservice that communicate on the same LAN. The Pocket PC has no problem consuming strings returned from the web service methoeds but...
1
by: djp | last post by:
Hi I add web reference to my C# client app and call web method that returns TreeNode. I tried to cast WebService TreeNode to Windows Forms TreeNode, but without any effect. Any ideas? Thanks...
6
by: Peter | last post by:
I have a WebService which returns a List of RunningReport class How do I read this XML data on the client side. How do I convert List<RunningReportfrom the WebService side to List<RunningReporton...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.