W
Wayne Brantley
I have found what appears to be an error in streaming with Datasets. It
causes an error of 'Cannot find relation 0' when recreating the dataset from
a stream.
Here is how you reproduce it.
Lets assume you have tables like this:
Customers
CustomerName: Varchar(50)
CustomerNumber: Int (Primary Key)
Addresses:
CustomerID: Int (Foreign Key)
Street: varchar(40)
Using the dataset designer and a database with a master-detail relationship
on it:
Drop the 'Master' table (Customers) and 'detail' table (Addresses) and
create the relationship between the CustomerID field between them using drag
and drop in the dataset designer.
Now, add a field to the detail dataset (Addresses) and call it
'CustomerName'. Set the expression of this new field to
'Parent.CustomerName'.
Now using whatever means necessary, load the dataset with data.
Everything will work as expected - no problems.
Using ASP.NET assign the dataset above to the session (causing it to be
streamed):
HttpContext.Current.Session["test"]=dset;
Now load it from the stream:
Mydatasettype dset=(Mydatasettype)Session["test"];
You will get the error when it streams back. If you remove the expression
of 'Parent.CustomerName' from the dataset definition the error will go
away...
Can I please get help/fix/etc?
Wayne
Here is the complete error info...
Source Error:
Line 74: this.CaseSensitive = ds.CaseSensitive;
Line 75: this.EnforceConstraints = ds.EnforceConstraints;
Line 76: this.Merge(ds, false,
System.Data.MissingSchemaAction.Add);
Line 77: this.InitVars();
Line 78: }
Source File: loginandrights.cs Line: 76
Stack Trace:
[IndexOutOfRangeException: Cannot find relation 0.]
System.Data.DataTableRelationCollection.get_Item(Int32 index)
System.Data.LookupNode.Bind(DataTable table, ArrayList list)
System.Data.DataExpression.Bind(DataTable table)
System.Data.DataExpression..ctor(String expression, DataTable table, Type
type)
System.Data.DataColumn.set_Expression(String value)
System.Data.Merger.MergeSchema(DataTable table)
System.Data.Merger.MergeTableData(DataTable src)
System.Data.Merger.MergeDataSet(DataSet source)
System.Data.DataSet.Merge(DataSet dataSet, Boolean preserveChanges,
MissingSchemaAction missingSchemaAction)
LoginAndRights..ctor(SerializationInfo info, StreamingContext context) in
loginandrights.cs:76
[TargetInvocationException: Exception has been thrown by the target of an
invocation.]
System.Reflection.RuntimeConstructorInfo.SerializationInvoke(Object
target, SerializationInfo info, StreamingContext context) +0
System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object
obj, SerializationInfo info, StreamingContext context) +149
System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder
holder) +128
System.Runtime.Serialization.ObjectManager.DoFixups() +170
System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler
handler, __BinaryParser serParser, Boolean fCheck, IMethodCallMessage
methodCallMessage) +269
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream
serializationStream, HeaderHandler handler, Boolean fCheck,
IMethodCallMessage methodCallMessage) +183
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream
serializationStream) +11
System.Web.Util.AltSerialization.ReadValueFromStream(BinaryReader reader)
System.Web.SessionState.SessionDictionary.Deserialize(BinaryReader
reader)
System.Web.SessionState.StateClientManager.Deserialize(Stream stream,
Int32 lockCookie)
System.Web.SessionState.SqlStateClientManager.DoGet(String id, SqlCommand
cmd)
System.Web.SessionState.SqlStateClientManager.GetExclusive(String id)
System.Web.SessionState.StateClientManager.BeginGetExclusiveSync(String
id, AsyncCallback cb, Object state)
System.Web.SessionState.SqlStateClientManager.System.Web.SessionState.IStateClientManager.BeginGetExclusive(String
id, AsyncCallback cb, Object state)
System.Web.SessionState.SessionStateModule.GetSessionStateItem()
System.Web.SessionState.SessionStateModule.BeginAcquireState(Object
source, EventArgs e, AsyncCallback cb, Object extraData)
System.Web.AsyncEventExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously)
causes an error of 'Cannot find relation 0' when recreating the dataset from
a stream.
Here is how you reproduce it.
Lets assume you have tables like this:
Customers
CustomerName: Varchar(50)
CustomerNumber: Int (Primary Key)
Addresses:
CustomerID: Int (Foreign Key)
Street: varchar(40)
Using the dataset designer and a database with a master-detail relationship
on it:
Drop the 'Master' table (Customers) and 'detail' table (Addresses) and
create the relationship between the CustomerID field between them using drag
and drop in the dataset designer.
Now, add a field to the detail dataset (Addresses) and call it
'CustomerName'. Set the expression of this new field to
'Parent.CustomerName'.
Now using whatever means necessary, load the dataset with data.
Everything will work as expected - no problems.
Using ASP.NET assign the dataset above to the session (causing it to be
streamed):
HttpContext.Current.Session["test"]=dset;
Now load it from the stream:
Mydatasettype dset=(Mydatasettype)Session["test"];
You will get the error when it streams back. If you remove the expression
of 'Parent.CustomerName' from the dataset definition the error will go
away...
Can I please get help/fix/etc?
Wayne
Here is the complete error info...
Source Error:
Line 74: this.CaseSensitive = ds.CaseSensitive;
Line 75: this.EnforceConstraints = ds.EnforceConstraints;
Line 76: this.Merge(ds, false,
System.Data.MissingSchemaAction.Add);
Line 77: this.InitVars();
Line 78: }
Source File: loginandrights.cs Line: 76
Stack Trace:
[IndexOutOfRangeException: Cannot find relation 0.]
System.Data.DataTableRelationCollection.get_Item(Int32 index)
System.Data.LookupNode.Bind(DataTable table, ArrayList list)
System.Data.DataExpression.Bind(DataTable table)
System.Data.DataExpression..ctor(String expression, DataTable table, Type
type)
System.Data.DataColumn.set_Expression(String value)
System.Data.Merger.MergeSchema(DataTable table)
System.Data.Merger.MergeTableData(DataTable src)
System.Data.Merger.MergeDataSet(DataSet source)
System.Data.DataSet.Merge(DataSet dataSet, Boolean preserveChanges,
MissingSchemaAction missingSchemaAction)
LoginAndRights..ctor(SerializationInfo info, StreamingContext context) in
loginandrights.cs:76
[TargetInvocationException: Exception has been thrown by the target of an
invocation.]
System.Reflection.RuntimeConstructorInfo.SerializationInvoke(Object
target, SerializationInfo info, StreamingContext context) +0
System.Runtime.Serialization.ObjectManager.CompleteISerializableObject(Object
obj, SerializationInfo info, StreamingContext context) +149
System.Runtime.Serialization.ObjectManager.FixupSpecialObject(ObjectHolder
holder) +128
System.Runtime.Serialization.ObjectManager.DoFixups() +170
System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler
handler, __BinaryParser serParser, Boolean fCheck, IMethodCallMessage
methodCallMessage) +269
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream
serializationStream, HeaderHandler handler, Boolean fCheck,
IMethodCallMessage methodCallMessage) +183
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream
serializationStream) +11
System.Web.Util.AltSerialization.ReadValueFromStream(BinaryReader reader)
System.Web.SessionState.SessionDictionary.Deserialize(BinaryReader
reader)
System.Web.SessionState.StateClientManager.Deserialize(Stream stream,
Int32 lockCookie)
System.Web.SessionState.SqlStateClientManager.DoGet(String id, SqlCommand
cmd)
System.Web.SessionState.SqlStateClientManager.GetExclusive(String id)
System.Web.SessionState.StateClientManager.BeginGetExclusiveSync(String
id, AsyncCallback cb, Object state)
System.Web.SessionState.SqlStateClientManager.System.Web.SessionState.IStateClientManager.BeginGetExclusive(String
id, AsyncCallback cb, Object state)
System.Web.SessionState.SessionStateModule.GetSessionStateItem()
System.Web.SessionState.SessionStateModule.BeginAcquireState(Object
source, EventArgs e, AsyncCallback cb, Object extraData)
System.Web.AsyncEventExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute()
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously)