After installing .NET 4.5, our existing code that currently runs on .NET 4.0 is throwing exceptions when assigning data source to DataGridView (note that it was working fine before .NET 4.5, and continues to work when 4.5 is uninstalled... but for several reasons we have to have .NET 4.5 on clients computers):
dgrManagers.DataSource = mManagers;
//where mManagers is System.Collections.ObjectModel.ObservableCollection<IManager>; the collection has 0 items.
//and dgrManagers is an instance of class that extends from Infragistics UltraGrid (Infragistics.Win.UltraWinGrid.v5.2.dll, v5.2.20052.1053).
//Extending is for style purposes, no grid content is referenced.
Previous to this, the grid was initialized (once) with:
foreach (UltraGridColumn c in dgrManagers.DisplayLayout.Bands[0].Columns) { switch (c.Key) { case "FullName": c.Header.Caption = "Full name"; c.Header.VisiblePosition = 0; c.Width = dgrManagers.Width - 30; break; default: c.Hidden = true; break; } } dgrManagers.HasLayout = true;
Errors specifics:
HResult: -2147024809
Assemlby: {Infragistics.Shared.v5.2, Version=5.2.20052.1053, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb}
Key already exists Parameter name: Key
at Infragistics.Shared.KeyedSubObjectsCollectionBase.ValidateKeyDoesNotExist(String key, IKeyedSubObject ignoreObject) at Infragistics.Shared.KeyedSubObjectsCollectionBase.ValidateKey(String key, IKeyedSubObject ignoreObject) at Infragistics.Shared.KeyedSubObjectsCollectionBase.ValidateKey(String key) at Infragistics.Shared.KeyedSubObjectsCollectionBase.InternalAdd(IKeyedSubObject obj) at Infragistics.Win.UltraWinGrid.ColumnsCollection.InternalAdd(UltraGridColumn column) at Infragistics.Win.UltraWinGrid.UltraGridBand.InitColumns(UltraGridBand[] oldBands) at Infragistics.Win.UltraWinGrid.UltraGridBand.InitListManager(BindingManagerBase bindingManager, String dataMember, UltraGridBand[] oldBands) at Infragistics.Win.UltraWinGrid.UltraGridLayout.ListManagerUpdated(BindingManagerBase bindingManager) at Infragistics.Win.UltraWinGrid.UltraGridLayout.ListManagerUpdated() at Infragistics.Win.UltraWinGrid.UltraGridBase.Set_ListManager(Object newDataSource, String newDataMember) at Infragistics.Win.UltraWinGrid.UltraGridBase.set_DataSource(Object value)
I understand this is an old version of Infragistics, but we're not ready to switch to new one (even though we have some newer licences) since the project is quite huge and has been working for quite some time, and I'm afraid it would cause even more errors if the new version is not fully backward compatible.
Does anyone have any idea how to circumvent this problem? Any help/hint is appreciated...
Thanks,
Veljko
So far, I've been able to pinpoint the problem. The IManager extends from some other interface that has the same properties, e.g.:
public interface IIdentifyable{
string Identifier{get;set;}
}
public interface IManager : IIdentifyable{
string Identifier{get;set;} //should be with "new" in front to hide inherited member, but it breaks anyway
string FirstName {get;set;}
string LastName {get;set;}
When this is bound to UltraGrid, it throws exception, saying it has duplicate keys. When I remove inheritance from IManager to IIdentifyable, everything works. I'm guessing it's using reflection to get to column keys, but this:
foreach(var prop in typeof(IManager).GetProperties())
Console.WriteLine("Prop name = " + prop.Name);
doesn't output any duplicates. So how is it that the UltraGrid is getting the column names/keys based on object type?
Hi,
You are probably right. Microsoft made some changes in CLR4 and we had to change around certain interfaces we were using in the WinGrid and some other assemblies that deal with data binding.
These issues are fixed in the latest version of NetAdvantage.
NetAdvantage 2005 is, of course, not supported in DotNet CLR4, since that version of NetAdvantage was retired years before CLR4 was release.
Hi Mike
We still encounter the same problem on Version 12.1.20121.2050, CLR4
Should it be solved?
Kind Regards,
Urs Scherrer
Hi Urs,
If you are getting the same exception in 12.1 then something is wrong and this probably is not the issue I was thinking of.
Can you post a small sample project demonstrating the exception so we can check it out and get it fixed?
Hi
First excuse my mutliple posting. I always got an error from the website and thought my post was not saved.
In the meantime we found a workaraound which maybe points to the original problem:
We bound an UltraCombo to a "List<ICustomer>"
ICustomer derives from ISomethingElse and had properties which were marked "new" overriding properties from base interface.We just removed the 3 properties from ICustomer and this solved the problem.
public interface ICustomer: ISomethingElse { new int ValueMember { get; set;} new string DisplayMember { get; set;} new IListenObjekt Instanz { get; } ... }
public interface ISomethingElse { int ValueMember { get; set;} string DisplayMember { get; set;} IListenObjekt Instanz { get; } }
Probably Infragistics (or a .NET call) returns the proerpties from ICustomer AND ISomethingElse which then generated "Key already Exists".
Kind regardsUrs Scherrer
Hello Urs,
I created the following case for you: 'CAS-101749-K5X9R7' and will update you through it.
Hi everybody,
today I downloaded IG 2012.2 (Version 12.2.20122.1006) and upgraded our project, but this issue is still there...
Regards,
Wolfgang