Ilia

Hi,

I receive the following exception when trying to submit changes made in a database backed class.

Test method UserManagerTest.MyTest threw exception: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index.

at System.Collections.BitArray.Get(Int32 index)
at System.Data.DLinq.SimpleTrackedObject.HasChanged(MetaDataMember mm) in C:\Program Files\LINQ Preview\Bin\Disasm\System.Data.DLinq.il:line 106219
at System.Data.DLinq.SimpleTrackedObject.<GetDataChanges>d__0.MoveNext() in C:\Program Files\LINQ Preview\Bin\Disasm\System.Data.DLinq.il:line 105226
at System.Data.DLinq.SimpleChangeDirector.GetUpdateCommand(TrackedObject tracked) in C:\Program Files\LINQ Preview\Bin\Disasm\System.Data.DLinq.il:line 3318
at System.Data.DLinq.SimpleChangeDirector.Update(TrackedObject item) in C:\Program Files\LINQ Preview\Bin\Disasm\System.Data.DLinq.il:line 2615
at System.Data.DLinq.ChangeProcessor.SubmitChanges(ConflictMode failureMode) in C:\Program Files\LINQ Preview\Bin\Disasm\System.Data.DLinq.il:line 4123
at System.Data.DLinq.DataContext.SubmitChanges(ConflictMode failureMode) in C:\Program Files\LINQ Preview\Bin\Disasm\System.Data.DLinq.il:line 7690
at System.Data.DLinq.DataContext.SubmitChanges() in C:\Program Files\LINQ Preview\Bin\Disasm\System.Data.DLinq.il:line 7642
at UserManager.SubmitChanges() in c:\Users\UserManager.cs:line 196
at UserManagerTest.MyTest() in C:\Users\UserManagerTest.cs:line 183

From what I understand you are trying to read SimpleTrackedObject::dirtyMemberCache bit array using index of a class member from MetaDataMember::Ordinal. It is not quite correct when class definition contains properties which are not market with [Column] attribute between properties with this attribute.

Workaround that works for me is moving all the properties without [Column] attribute down in the class definition.

Hope you can fix it in the next LINQ release.

Thanks



Re: LINQ Project General ArgumentOutOfRangeException in SubmitChanges

Mathew Charles

Thanks for pointing this out and posting a work around. I'll log a bug.




Re: LINQ Project General ArgumentOutOfRangeException in SubmitChanges

polease

I want to query if this has been fixed in .net 3.0 RC1 release




Re: LINQ Project General ArgumentOutOfRangeException in SubmitChanges

JasonCooke_MSFT

The LINQ features are part of the next Visual Studio release, which is version 3.5 of the .NET Framework.

.NET 3.0, which will be a part of Vista, does not contain LINQ.





Re: LINQ Project General ArgumentOutOfRangeException in SubmitChanges

polease

Thanks,  is there anyway I can get a version in which this has been fixed right now 'cause we are working on a project using LINQ.

BTW, is there anyplace where I can find a matrix that for each version what is the feature inside and what bugs have been fixed I'm really want a piece of that either.






Re: LINQ Project General ArgumentOutOfRangeException in SubmitChanges

MamboJoel

BTW, we've noticed this exception happend when calling SubmitChange() twice...




Re: LINQ Project General ArgumentOutOfRangeException in SubmitChanges

MamboJoel

Also,
1. we've found out that the workaround (post #1) is not only about properties market with the column attribute, but also with the association attribute.
2. looks like all non mapped properties must be in the same partial class than the mapped ones and not inside a region.




Re: LINQ Project General ArgumentOutOfRangeException in SubmitChanges

Matt Warren

The bug has been fixed and will appear in the Visual Studio "Orcas" beta.




Re: LINQ Project General ArgumentOutOfRangeException in SubmitChanges

Nathan Stott

How is this a valid work-around if you are using partial classes and sql metal

This bug is crippling my ability to use Linq.

The entire idea of dlinq and sqlmetal is that you use sqlmetal to generate your business objects and then have partial classes in a seperate file for your business logic.

This bug is popping up everywhere in my tests. Moving the update function around in my partial classes will get rid of the error, but if I make a DB change and rerun SqlMetal or if I edit my partial class, it often reappears and I have to move the update function to another spot in the partial class. The front, the end, the middle... the sweet spot to place my update method seems impossible to determine.

Do you have any suggestions for those of us using partial classes and sqlmetal

Thanks,
Nathan




Re: LINQ Project General ArgumentOutOfRangeException in SubmitChanges

Nathan Stott

MamboJoel wrote:

2. looks like all non mapped properties must be in the same partial class than the mapped ones and not inside a region.


Do you mean that the non-mapped properties must be in the same partial class as the mapped properties or that they must be in a seperate partial class by themselves

Thanks,
Nathan




Re: LINQ Project General ArgumentOutOfRangeException in SubmitChanges

polease

I have ever seen someplace that said the positioning of properties matter. That is, you must put the none-mapped properties after all other mapped property. I have no knowledge about how the compiler to link partial class together, but what I have done is copy the custom partial class behind the generated one in the same cs file. This works.




Re: LINQ Project General ArgumentOutOfRangeException in SubmitChanges

cronic76

Hello,

I'm experiencing a similiar version of this error, but I believe the cause may be slightly different and the posted workaround doesn't seem to avoid the bug.

I've got a single abstract class, Category, which represents the Categories table in the database. Each derived class is another type of Category that's stored in the same database table. This bug arises when the DataContext is tracking any of the derived Category types that contain more than one non-decorated properties and then SubmitChanges is called. For example, the below Category type causes no errors when SubmitChanges is called:

public class Subcategory : Category
{
public int One { get { return 1; } }
}

This class, however, causes an ArgumentOutOfRange at System.Collections.BitArray.Get when SubmitChanges is called:

public class Subcategory : Category
{
public int One { get { return 1; } }
public int Two { get { return 2; } }
}

Despite this, I can add any number of properties decorated with an AssociationAttribute or ColumnAttribute and there are no problems, so long as I limit myself to no more than one non-decorated property. No adjustments in the order in which the members are declared seem to affect this bug.

Any suggestions on how I may work around this problem are greatly appreciated. I'm building a new framework based on this incredible, Linq-enlightened way of doing things and I'd like to continue development between now and the release of the fixed-up version of DLinq (Februrary, right ). Thanks!

cronic





Re: LINQ Project General ArgumentOutOfRangeException in SubmitChanges

cronic76

I found that my previously posted problem can be corrected by taking advantage of the PropertyChanging/Changed events in my entity objects. It seems that when DLinq subscribes to those events for change tracking, it doesn't do whatever it was doing to throw an exception. Problem solved =)





Re: LINQ Project General ArgumentOutOfRangeException in SubmitChanges

Kofi J.

I have still the same problem:

System.ArgumentOutOfRangeException was unhandled
Message="Der Index lag auserhalb des Bereichs. Er muss nicht negativ und kleiner als die Auflistung sein.\r\nParametername: index"
Source="mscorlib"
ParamName="index"
StackTrace:
bei System.Collections.BitArray.Get(Int32 index)
bei System.Data.DLinq.SimpleTrackedObject.HasChanged(MetaDataMember mm)
bei System.Data.DLinq.SimpleTrackedObject.HasDataChanges()
bei System.Data.DLinq.ChangeProcessor.SubmitChanges(ConflictMode failureMode)
bei System.Data.DLinq.DataContext.SubmitChanges(ConflictMode failureMode)
bei System.Data.DLinq.DataContext.SubmitChanges()
bei HerosServer.DatabaseControl.UpdateDatabaseThreadMethod() in C:\Dokumente und Einstellungen\Kofi\Eigene Dateien\Visual Studio 2005\Projects\Heros\Server\HerosServer\Program.cs:Zeile 77.
bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)
bei System.Threading.ExecutionContext.runTryCode(Object userData)
bei System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
bei System.Threading.ThreadHelper.ThreadStart()
InnerException:

I am using

Microsoft Visual Studio Codename Orcas Version 9.0.20404.0 Beta1, Microsoft .NET Framework Version 2.0.50727

The first time I call the Method it works!

Every further call will throw an ArgumentOutOfRangeException

Is there a working solution to to make it workin'

Kofi





Re: LINQ Project General ArgumentOutOfRangeException in SubmitChanges

Mathew Charles

Can you please provide your data context and entity mapping classes, as well as the code calling submit changes so I can investigate the issue

Thanks,

-Mathew (MSFT)