473,385 Members | 1,506 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,385 software developers and data experts.

Serializable ?

WJ
I have this class:

******************************************
using System;

namespace myNameSpace.DBRec
{
[Serializable]
public class myRec
{
private string _Field1;
private string _Field2;

public myRec()
{
}

public myRec
(
string Field1
,string Field2
)
{
this._Field1=Field1;
this._Field2=Field2;
}

public string Field1
{
get
{
return _Field1;
}
set
{
Field1=value;
}
}

public string Field2
{
get
{
return _Field2;
}
set
{
Field2=value;
}
}
}
}
******************************************

In my asp.net page, I have:

private string F1="test1";
private string F2="test2";

1. If I call this:

myRec mr=new myRec(F1,F2); then there is no problem.

2. However, if I do these:

myRec mr=myRec();
mr.Field1=F1;
mr.Field2=F2;

then I got the exception below.
Server Error in '/myDotNet' Application.
--------------------------------------------------------------------------------

Exception of type System.StackOverflowException was thrown.
Description: An unhandled exception occurred during the execution of the
current
web request. Please review the stack trace for more information about the
error
and where it originated in the code.

Exception Details: System.StackOverflowException: Exception of type
System.StackOverflowException was thrown.

Source Error:

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be
identified using the exception stack trace below.

Stack Trace:

[StackOverflowException: Exception of type System.StackOverflowException was
thrown.]

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework
Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032

Thanks for your help,

John

Nov 18 '05 #1
4 1161
Its because your Field1.Set is circular. Instead of setting the interval
variable _Field1, it ends up calling itself, the Field1.Set by attempting to
do this.Field1 = value;. The Field2.Set has the same problem.

Hope this helps!

Joel Cade, MCSD
Fig Tree Solutions, LLC
http://www.figtreesolutions.com

"WJ" wrote:
I have this class:

******************************************
using System;

namespace myNameSpace.DBRec
{
[Serializable]
public class myRec
{
private string _Field1;
private string _Field2;

public myRec()
{
}

public myRec
(
string Field1
,string Field2
)
{
this._Field1=Field1;
this._Field2=Field2;
}

public string Field1
{
get
{
return _Field1;
}
set
{
Field1=value;
}
}

public string Field2
{
get
{
return _Field2;
}
set
{
Field2=value;
}
}
}
}
******************************************

In my asp.net page, I have:

private string F1="test1";
private string F2="test2";

1. If I call this:

myRec mr=new myRec(F1,F2); then there is no problem.

2. However, if I do these:

myRec mr=myRec();
mr.Field1=F1;
mr.Field2=F2;

then I got the exception below.
Server Error in '/myDotNet' Application.
--------------------------------------------------------------------------------

Exception of type System.StackOverflowException was thrown.
Description: An unhandled exception occurred during the execution of the
current
web request. Please review the stack trace for more information about the
error
and where it originated in the code.

Exception Details: System.StackOverflowException: Exception of type
System.StackOverflowException was thrown.

Source Error:

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be
identified using the exception stack trace below.

Stack Trace:

[StackOverflowException: Exception of type System.StackOverflowException was
thrown.]

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework
Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032

Thanks for your help,

John

Nov 18 '05 #2
Is the following a typo?

myRec mr=myRec();

It's missing the new operator.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"WJ" <Jo*******@HotMail.Com> wrote in message
news:eS**************@tk2msftngp13.phx.gbl...
I have this class:

******************************************
using System;

namespace myNameSpace.DBRec
{
[Serializable]
public class myRec
{
private string _Field1;
private string _Field2;

public myRec()
{
}

public myRec
(
string Field1
,string Field2
)
{
this._Field1=Field1;
this._Field2=Field2;
}

public string Field1
{
get
{
return _Field1;
}
set
{
Field1=value;
}
}

public string Field2
{
get
{
return _Field2;
}
set
{
Field2=value;
}
}
}
}
******************************************

In my asp.net page, I have:

private string F1="test1";
private string F2="test2";

1. If I call this:

myRec mr=new myRec(F1,F2); then there is no problem.

2. However, if I do these:

myRec mr=myRec();
mr.Field1=F1;
mr.Field2=F2;

then I got the exception below.
Server Error in '/myDotNet' Application.
-------------------------------------------------------------------------- ------
Exception of type System.StackOverflowException was thrown.
Description: An unhandled exception occurred during the execution of the
current
web request. Please review the stack trace for more information about the
error
and where it originated in the code.

Exception Details: System.StackOverflowException: Exception of type
System.StackOverflowException was thrown.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be
identified using the exception stack trace below.

Stack Trace:

[StackOverflowException: Exception of type System.StackOverflowException was thrown.]

-------------------------------------------------------------------------- ------ Version Information: Microsoft .NET Framework
Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032

Thanks for your help,

John

Nov 18 '05 #3
WJ

"Kevin Spencer" <ks******@takempis.com> wrote in message
news:OI**************@tk2msftngp13.phx.gbl...
Is the following a typo?

myRec mr=myRec();

It's missing the new operator.

Yes it did. It is to be "new" always otherwise it would not pass the
compiler.

John
Nov 18 '05 #4
WJ

"Joel Cade" <jo**@nospam.figtreesolutions.com> wrote in message
news:BC**********************************@microsof t.com...
Its because your Field1.Set is circular. Instead of setting the interval
variable _Field1, it ends up calling itself, the Field1.Set by attempting
to
do this.Field1 = value;. The Field2.Set has the same problem.

Thanks

John
Nov 18 '05 #5

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

Similar topics

3
by: Magnus Byne | last post by:
Hi, I have a problem using serializable transactions. In one transaction I select a single specific row from a table using a where clause (this causes it to acquire and hold a range lock). In...
0
by: xmail123 | last post by:
Hi, Hi, As was pointed out whatever you return from a WebMethod needs to be serializable to SOAP. An ArrayList is not serializable. I will be needing to return other data types from web...
8
by: xmail123 | last post by:
Hi, As was pointed out whatever you return from a WebMethod needs to be serializable to SOAP. An ArrayList is not serializable. I will be needing to return other data types from web methods. ...
5
by: Ben Terry | last post by:
I get the following compilation error: "The type or namespace name 'Serializable' could not be found (are you missing a using directive or an assembly reference?)" Can anyone tell me why the...
0
by: Poewood | last post by:
I am experimenting with saving files in binary format on the Pocket PC. When I use the attribute I get error in Compact Framework. Do i have to use the attribute to make a class serializable? ...
2
by: John | last post by:
Hi What is a Serializable class compared to a normal class? Thanks Regards
9
by: Developer | last post by:
Hi, How can one tell wsdl.exe/VS.NET web service proxy generatioon to to put on imported classes? For example, i fin your web service you use a class: class Data { }
1
by: cpnet | last post by:
I have a DataTable defined in a strongly-typed DataSet: public class MyDataSet: DataSet... { ... public class MyDataTable: DataTable... { ...}
3
by: Techno_Dex | last post by:
I'm wanting to create a Wrapper (or Extender depending on how you look at it) for a Serializable object that I then want to send over a webservice. Basically I want to create a Serializable Object,...
8
by: Techno_Dex | last post by:
Has anyone come up with a slick way to make Custom Serializable Objects to behave like DataSets when using WebServices? What I'm looking for is some way to force the WSDL generated code to create...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.