474,052 Members | 2,347 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Howto: Programmaticall y serialization Entry Method Parameters ( their values ) ?

Howto: Programmaticall y serialization Entry Method Parameters ( their
values ) ?

See example below:

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

// i will dynamic (programmatical ly) 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 2822
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.co m

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

See example below:

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

// i will dynamic (programmatical ly) 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.c omnapisał w wiadomo¶ci
news:%2******** ********@TK2MSF TNGP03.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.co m

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

See example below:

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

// i will dynamic (programmatical ly) 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
2891
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 loop through all the forms in a database and pull information about the form (controls and properties). We would need to do the same in our VB.NET project; loop through the project and get the web form's control and property information...
37
5074
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 signature. When developing this lib, I figured that the pointer-to-member-function, although seemingly an attractive solution, does not work well for us.
6
8365
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 the dreaded <elementname xmlns=''> was not expected exception. If I comment out the XmlTypeAttribute, it works just fine. Just so you know, when I instantiate an instance of an XmlSerializer, I pass a default namespace to the ctor. ...
0
2364
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 to application server, I did not get the result in the C# client side, I used a soap monitor to look at the SOAP messages that were exchanged, I can see server returned a correct SOAP message, but the C# client failed to deserialize the XML...
4
2365
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. Therefore the application errors out when deserializing the xml data. It places the some part of the child element
5
2852
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 like it to return an XML serialized version of an object.
11
11987
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 streams. I ran the test for 50K, 100K, 500K iterations, where each iteration consists of sending an object from a client process to a server process, and the server process sends back an ack. Here are the results: .NET Remoting C++...
6
2588
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 PropertyInfo and the ParameterInfo stuff, but I can't possibly know the range of valid values nor what the underlying storage is. How is this normally handled? Should I just ignore the indexer and simply serialize the fields?
0
4729
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 lifetime of those objects lasts only as long as the Java virtual machine is running. Once we close the JVM, we lose all those objects. What if someone wants objects to be available after JVM restarts? This is where Serialization comes into play. ...
0
10364
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11623
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
12058
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10345
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8727
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7886
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6677
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6877
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3993
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.