473,499 Members | 1,653 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Howto: Programmatically serialization Entry Method Parameters ( their values ) ?

Howto: Programmatically serialization Entry Method Parameters ( their
values ) ?

See example below:

public static void C(string Code, string Name) {

// i will dynamic (programmatically) serialization method entry parameters -
( their values )

StackTrace t = new StackTrace(true);

StackFrame ff = t.GetFrame(0);

foreach (ParameterInfo pi in ff.GetMethod().GetParameters())

{

Stream stream = File.Create("C:\\a.xml");

SoapFormatter soap = new SoapFormatter();
// soap.Serialize(stream, values of entry parameters );

stream.Close();

}
return;

}

Regards,

P.
Mar 21 '07 #1
2 2781
Pawel,

You can't do that. The StackFrame doesn't offer up access to the
parameter values. Unless you hook into the runtime (or pass them explicitly
to your method) there is no way you will be able to do this.

Additionally, if this is a general mechanism, it is most likely going to
fail, as not all types in the framework are marked as serializable.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Pawel" <pa********@wp.plwrote in message
news:uS**************@TK2MSFTNGP02.phx.gbl...
Howto: Programmatically serialization Entry Method Parameters ( their
values ) ?

See example below:

public static void C(string Code, string Name) {

// i will dynamic (programmatically) serialization method entry
parameters - ( their values )

StackTrace t = new StackTrace(true);

StackFrame ff = t.GetFrame(0);

foreach (ParameterInfo pi in ff.GetMethod().GetParameters())

{

Stream stream = File.Create("C:\\a.xml");

SoapFormatter soap = new SoapFormatter();
// soap.Serialize(stream, values of entry parameters );

stream.Close();

}
return;

}

Regards,

P.


Mar 21 '07 #2
Thanks.

Regards,
P.
Użytkownik "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.comnapisał w wiadomo¶ci
news:%2****************@TK2MSFTNGP03.phx.gbl...
Pawel,

You can't do that. The StackFrame doesn't offer up access to the
parameter values. Unless you hook into the runtime (or pass them
explicitly to your method) there is no way you will be able to do this.

Additionally, if this is a general mechanism, it is most likely going
to fail, as not all types in the framework are marked as serializable.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Pawel" <pa********@wp.plwrote in message
news:uS**************@TK2MSFTNGP02.phx.gbl...
>Howto: Programmatically serialization Entry Method Parameters ( their
values ) ?

See example below:

public static void C(string Code, string Name) {

// i will dynamic (programmatically) serialization method entry
parameters - ( their values )

StackTrace t = new StackTrace(true);

StackFrame ff = t.GetFrame(0);

foreach (ParameterInfo pi in ff.GetMethod().GetParameters())

{

Stream stream = File.Create("C:\\a.xml");

SoapFormatter soap = new SoapFormatter();
// soap.Serialize(stream, values of entry parameters );

stream.Close();

}
return;

}

Regards,

P.



Mar 21 '07 #3

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

Similar topics

6
2816
by: ALthePal | last post by:
Hi, I'm not sure if we are able to or even how to loop through the web forms in a VB.NET project during design time. In MSAccess we are able to go through the database -> forms collection and...
37
4943
by: Ben | last post by:
Hi, there. Recently I was working on a problem where we want to save generic closures in a data structure (a vector). The closure should work for any data type and any method with pre-defined...
6
8314
by: David B. Bitton | last post by:
I am having a problem deserializing XML when the root node is missing a namespace declaration. My Type has an XmlTypeAttribute with a namespace defined. If I attempt to deserialize the XML, I get...
0
2308
by: psy000 | last post by:
Hi, I have a C# web service client that talks to a JAVA application sever. I use AXIS to generate the WSDL file, use wsdl.exe to generate proxy stub c# code. When I try to use c# client connect...
4
2305
by: ron | last post by:
Hi, I have class object that i serialize using the System.Xml.Serialization class. Intermittently the object is not getting serialized correctly, using System.Xml.Serialization classes....
5
2811
by: francois | last post by:
First of all I would to to apologize for resending this post again but I feel like my last post as been spoiled Here I go for my problem: Hi, I have a webservice that I am using and I would...
11
11925
by: ajou_king | last post by:
I was running some tests on my Win32 1GHZ processor to see how long it would take to transmit objects numerous times via TCP/IP using C# ..NET Remoting vs the C++ trustworthy method of binary...
6
2550
by: Pete Davis | last post by:
I'm writing an XML serializer (similar to the MS XMLSerializer). It uses reflection to get the values from a class/struct. The one area I'm confused on is indexers. I can get the indexer...
0
4695
by: JosAH | last post by:
Introduction Upon hearing the word, "Serialization", the first question which comes to mind is ... "What is Serialization?" We know that we can create resusable objects in Java. But the...
0
7131
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,...
1
6894
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
5470
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,...
1
4919
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...
0
4600
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3099
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3091
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.