473,406 Members | 2,620 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,406 software developers and data experts.

Using System.Exception.Data ??


A System.Exception has a Data property that I would like to add data to
before I call my standard exception handler. When in a routine that uses SQL
server I would like to add the
System.Data.SqlClient.SqlConnectionSQLConnection,
System.Data.SqlClient.SqlCommand and System.Data.SqlClient.SqlDataReader
when there is one.

Exception abc = new Exception("abc");
abc.Data.Add("TheConnection",TheConnection);
abc.Data.Add("TheSQLCommand", TheSQLCommand);
abc.Data.Add("Reader", TheReader);

This compiles but at run time an exception is thrown because these are not
serialiazable. How can I put these into the Excpetions data property?

Thanks
Jun 19 '06 #1
3 6318

You probably need to write your own Serlialiable class.

You will have 3 constructors.
Here is one of them.

public class MyClass
{
private SqlReader m_sr = null;
MyClass( SqlReader sr )
{
this.m_sr = sr;
}
}

You can try that and expose a property for m_sr.

However, you may have to parse m_sr and provide member variarbles/properties
for the items of m_sr you want to deal with.

Then you try this:

abc.Data.Add("MyClassKey" , new MyClass ( TheReader ));
I think thats a good way to try it. But its just an idea.


<ne***************@charter.net> wrote in message
news:t7*************@fe06.lga...

A System.Exception has a Data property that I would like to add data to
before I call my standard exception handler. When in a routine that uses SQL server I would like to add the
System.Data.SqlClient.SqlConnectionSQLConnection,
System.Data.SqlClient.SqlCommand and System.Data.SqlClient.SqlDataReader
when there is one.

Exception abc = new Exception("abc");
abc.Data.Add("TheConnection",TheConnection);
abc.Data.Add("TheSQLCommand", TheSQLCommand);
abc.Data.Add("Reader", TheReader);

This compiles but at run time an exception is thrown because these are not
serialiazable. How can I put these into the Excpetions data property?

Thanks

Jun 19 '06 #2
I have tried this with the same results.

Thanks
Jun 19 '06 #3
When I add a class attribute of:

[SerializableAttribute]

it works.

Thanks
Jun 19 '06 #4

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

Similar topics

2
by: James Cooke | last post by:
Hi all, I want to catch a duplicate key exception. I do not want to provide that verbose message from the MSSQL server - I would put a user friendly message out, like "The item you have added...
6
by: ransoma22 | last post by:
I developing an application that receive SMS from a connected GSM handphone, e.g Siemens M55, Nokia 6230,etc through the data cable. The application(VB.NET) will receive the SMS automatically,...
0
by: Ramon de Klein | last post by:
I try to serialize an exception using the SoapFormatter, but this is a little bit problematic. The MethodInfo tag of the serialized exception contains &x00 characters (ASCII 0x00) in its serialized...
1
by: Anonieko | last post by:
Understanding and Using Exceptions (this is a really long post...only read it if you (a) don't know what try/catch is OR (b) actually write catch(Exception ex) or catch{ }) The first thing I...
0
by: khubieb | last post by:
Simply I am trying to use RSACryptoServiceProvider to generate a key pair, send the public key to a service that will retrieve me data, encrypt it with my public key, send the encrypted data back...
8
by: Andrew Teece | last post by:
Hope someone can help. We are trying to deploy an ASP.Net 2.0 application to a 3-node webfarm. The application uses the ReportViewer control in local mode, hence we need session state. Because we...
7
by: bryant | last post by:
Hi all. I am new to ASP and working in Expression Web. The following query displays the information I need in the gridview for a single record. SELECT "OE_HDR"."ORD_NO", "OE_HDR"."CUST_NAM",...
4
by: kanepart2 | last post by:
I am making a simple program to use display SQL data using C# SqlConnection myConnection = new SqlConnection(@"Trusted_Connection=yes;database=*****database name*****;connection timeout=30"); ...
0
by: shlim | last post by:
Currently I'm using VB.Net to perform a http/https multipart form post to a servlet. I'm able to perform the post using HttpWebrequest via GetRequestStream(). However, the servlet returned me with...
4
ollyb303
by: ollyb303 | last post by:
Hi, wasn't sure whether I should post this under .net, IIS or access, but I've plumped for .net! I have a problem with an asp.net website which I am hosting on a windows server 2003 under IIS...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.