GenericParameterAttributes = '(dtResults).Category_CodeColumn.DataType.GenericParameterAttributes' threw an exception of type 'System.InvalidOperationException'
GenericParameterAttributes = '(dtResults).Category_CodeColumn.DataType.GenericParameterAttributes' threw an exception of type 'System.InvalidOperationException'
I am in the process of changing a C#.net web windows form application that connects all the databases to a project folder called 'dataadapters'. This application uses linq as part of the code and the generic classes. I basically need to change columns in the database since the production will be changing in a month or two. Right now i am getting the error
GenericParameterAttributes = '(dtResults).Category_CodeColumn.DataType.GenericParameterAttributes' threw an exception of type 'System.InvalidOperationException'.
I know the problem is related to the linq code,but iIdo not know how to get to the LINQ code. Part of the code might related to an embedded file.
How would you resolve this problem?
Generic-Linq Error in C#.net 2008
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Zoran HorvatRank #792 · 2.9K reputationPosted Jul 20, 2011, 10:59 AM EDT
You can read GenericParameterAttributes property only on Type instances which have IsGenericType property returning true.
To correct the issue you might do this:
Type dataType = (dbResult).Category_CodeColumn.DataType;
GenericParameterAttributes = (dataType.IsGenericParameter ? dataType.GenericParameterAttributes : null);
Zoran