|
ok, i guess i see how this is done-- pls correct me if i'm wrong: on invoking Formatter.Serialize, Formatter uses reflection to check whether ISerializable is implemented in the class of the object. if so it calls the interface. If not it uses reflection to serialize all the fields, checking for the NonSerialized as it goes.
is that what happens? and if this is, how is that done efficiently enough to not take forever to serialize each two-bit-- i mean two-byte-- object in the graph? does BinaryFormatter perform some sort of run time analysis or "compilation" like regex?
________________________________________
Gosh, it would be awful pleas'n, to reason out the reason, for things I can't explain.
Then perhaps I'd deserve ya, and be even worthy of ya..
if I only had a brain!
|
|
|
|
|
You should read Serializing Objects[^] in the .NET Framework. I think it'll help understand many of these concepts.
As far as performance, it is true that reflecting all those fields and Types takes a while but it is necessary when crossing contexts (via Remoting) or serialing to streams for any other means. The process of serialization is actually pretty complex. If you're interested in the details, you should use ildasm.exe (if you know IL) or a good decompiler like .NET Reflector[^] to see how much of that is done.
Our application I designed uses A LOT of Remoting in the Internet-deployed edition and it functions pretty fast - not much slower than the LAN version (and most people don't even notice). As far as I can tell, nothing is cached from serialization to serialization either because everything changes from call to call.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
thanks, yes i also use BinaryFormatter on pretty big objects and it seems remarkably efficient. Thanks for the suggestion on Reflector (do i also need to learn il?).
Thanks for the insights and the Reflector fishing rod!!
________________________________________
Gosh, it would be awful pleas'n, to reason out the reason, for things I can't explain.
Then perhaps I'd deserve ya, and be even worthy of ya..
if I only had a brain!
|
|
|
|
|
Why not learn IL? You can never know too much. Besides, decompilers don't always do such a great job so you'll have to look at IL at some point to see what's really going on. At least knowing what the instructions do is important, which is also documented in the .NET Framework SDK.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
yikes! i guess you're right, that probably is the key to a lot of things i wish i knew how they were implemented, but i must admit it sounds fairly daunting!!
also brings up a dumb question, is it obvious that the inner loop of the serialization (in BinaryFormatter?) would likely be written in IL not native x86?
Thx!
________________________________________
Gosh, it would be awful pleas'n, to reason out the reason, for things I can't explain.
Then perhaps I'd deserve ya, and be even worthy of ya..
if I only had a brain!
|
|
|
|
|
All compilers targeting the CLR using pure managed code produce Intermediate Language, or IL. So yes, it is IL. In fact, the Managed C++ compiler is the only compiler publicly available from Microsoft that can produce native code in an assembly (known as mixed mode).
But using an loop for serialization would be a poor idea. Recursion is most likely at work since for every Type that is added to the SerializationInfo , it has to be serialized, and then their Types, and so on so forth.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
By decorating your class with the Serializable attribute you are just telling other classes that you pass it to that it is "auto-serializable", by which it is meant that it contains no volatile references (i.e. a SQLConnection object) or references to other classes that are not serializable. This way a remoting object (for example) knows that it does not need any special instructions to serialize/deserialize.
DTrent
|
|
|
|
|
i hadn't thought about the volatile references, thanks!
________________________________________
Gosh, it would be awful pleas'n, to reason out the reason, for things I can't explain.
Then perhaps I'd deserve ya, and be even worthy of ya..
if I only had a brain!
|
|
|
|
|
I was working on POP3 mail application. I'm able to implement the POP3 protocol and get the mails and attachments.. etc. But i'm unable to decode some of the mails encoded by Quoted-Printable Content-Transfer-Encoding.
Please help ASAP.
|
|
|
|
|
If you're looking for the rules for decoding quoted-printable encodings, see RFC 1521: http://www.ietf.org/rfc/rfc1521.txt , section 5.1.
When you say you're unable to decode, is there some specific problem or are you just having problems with the rules required for decoding? The link above should help.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks Heath for your reply. But....
I needed the code in C# for decoding Quoted-Printable text.
|
|
|
|
|
Right, and there doesn't appear to be any examples you can use. There is one commercial ASP.NET emailing package that uses it but they didn't give any details.
Hence the RFC link - it isn't hard to do, so you should be able to figure it out. Mostly, it's just replacing certain characters with their hexidecimal equivalents prefixed by an equal sign. Use a StringBuilder for optimal performance.
Replace the characters as necessary and break the lines into 76 character sequences taking into account whether tabs or spaces must follow on the next line.
There was only one example in C# I could find, and if my German is any good, it seems to have problems in a couple cases. I tried tranlating the page, but apparently it was pretty bad grammar to start off with and the translation didn't do very well: http://www.mail-archive.com/csharp.net@glengamoi.com/msg00571.html[^].
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
If I host the SingleCall SAOs in IIS, I can use HttpContext.Current to get
current HttpContext in the calling method, so I can get some useful
information. But if I host the remote objects in a console application for
debug, HttpContext.Current is a null object. Can I get some object likes
HttpContext when I do not host the objects in IIS in the calling method? Iā
d not like to use CallContext cross Internet.
Best Regards!
|
|
|
|
|
HttpContext has no context outside of ASP.NET. It is tightly coupled, therefore not usable outside the context of ASP.NET.
You might consider designing your SAO to be a little more abstract and leave the details of what is required (say, a response Stream ) to the host.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thank for your comment.
I only need some way to distinguish clients in my SingleCall objects, but I'd not like to pass the client id in all class methods, or to pass the id in CallContext.
|
|
|
|
|
Define "client ID". We use a lot of remoting in our application and deal with lots of stuff like that. I just need to understand your circumstances. Is it unique to a machine (perhaps an IP address)? A user identity? A client application version or client name (like a user agent for browsers)?
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
In my software, I only need to distinguish sessions in the method calls. So I can generate a GUID in the client. But how can I passed to the server in SingleCall objects?
|
|
|
|
|
Well, there's always the CallContext , which you said you didn't want to use but this is a good purpose for it. What's wrong with it? It's just another part of the remoting infrastructure. Both creating your own RealProxy and adding a channel sink could possibly do this, but it's a lot more work and not easily accessible to the SAO itself, since creating your own proxy is more for modifying the params, returns, etc. of a message, and channel sinks are for manipulating the message typically without modifying the content (like compression, encryption, routing, etc.).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Very thanks! I don't want to use CallContext only because it will transmit all CallContext object content in both call and return, and it will use some network bandwidth.
|
|
|
|
|
The other methods I mentioned will be much harder to use. Frankly, the serialized ILogicalThreadAffinative implementation doesn't have to take much room if you just encapsulate basic Types like a String or a Guid . The channel sinks could take even more bandwidth than a CallContext if you're not mindful of the implementation. Besides, setting and getting objects from a CallContext is a heck of a lot easier than dealing with channel sinks. Once you read about them (again, that ".NET Remoting" book is good and gets in to that), I'm sure you'll agree!
Oh, and if you use CallContext.FreeNamedDataSlot in the server method with the name you used in the CallContext.SetData call on the client, there shouldn't be anything serialized and sent back in the return message. This could save you bandwidth easily.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Yes, you are right, and I also think CallContext is the better way in my solution, if HttpContext is invalid.
And thank you again for your help
|
|
|
|
|
hi,
i need to send web request to server.but i need to send request from using universal proxie servers. any one help to me. thanks in advance.
Murali.M
|
|
|
|
|
You mean send a request through a proxy? See the HttpWebRequest.Proxy property. There already is a WebProxy class that lets you specify the host, port, a list of addresses that don't require the proxy, and user credentials if logins are required. If this isn't sufficient, you'll notice that the HttpWebRequest.Proxy property is of type IWebProxy , you can implement that interface and make your own proxy. Set the proxy instance and call HttpWebRequest.GetResponse (inherited from WebRequest , so you'll have to cast the return to an HttpWebResponse for HTTP-specific properties).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hi,
thanks for ur help.
Have A Nice Day!
|
|
|
|
|
I wish to use the Dock property, but I need a 10 pixel inset on all 4 sides.
Let's say I am creating a simple editor. I place a TextBox control on a Form, but I'd like 10 pixel insets on every side of the TextBox.
One way:
Add a panel to the form, position the panel with 10 pixel insets on all 4 sides, and Anchor to all 4 sides. Then, attach the (Dock=Fill) TextBox to the panel panel.
Is there any way to do this without using a Panel like this?
I realize that if all I was creating was a text editor, then I could just Anchor the text box to all side of the form, and position the text box correctly, but, my real application is a bit more complicated. There are several controls inside the form - including a splitter. So, I can't really use Anchor for every case.
The crux of the problem is that when using the Dock property, the child control is docked right up against the edge of its parent. I was wondering if there was a property that could buffer or inset that child control.
I'd like to avoid having to add a Panel to my application everytime I want to position something just the way I like it - while using the Dock property. How about a thick transparent border?
FormBorderStyle will not work. I am working inside the form.
I'd also like to do this same thing for controls inside the form attached to parent Panels. I see that Panel can have a BorderStyle. Is there a way I can somehow customize the actual border?
I google "custom borders in C#" or something.
Thanks,
-Luther
|
|
|
|