It's difficult to say where is the problem, can you compare the refactored
code with the one that was workgin before?
No. I did'nt made backup before refactoring.
Have you use teh debug to see the type of the entity variable?
In immediate window entity.getType() returns:
{Name = "Klliik" FullName = ".EntityExtension.Klliik"}
[System.RuntimeType]: {Name = "Klliik" FullName =
"MyApp.EntityExtension.Klliik"}
base {System.Reflection.MemberInfo}: {Name = "Klliik" FullName =
"MyApp.EntityExtension.Klliik"}
Assembly: {-fnethhd, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null}
AssemblyQualifiedName: "MyApp.EntityExtension.Klliik, -fnethhd,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null"
Attributes: Public | BeforeFieldInit
BaseType: {Name = "Klliik" FullName = "MyApp.Entity.Klliik"}
ContainsGenericParameters: false
DeclaringMethod: 'entity.GetType().DeclaringMethod' threw an exception
of type 'System.InvalidOperationException'
DeclaringType: null
FullName: "MyApp.EntityExtension.Klliik"
GenericParameterAttributes:
'entity.GetType().GenericParameterAttributes' threw an exception of type
'System.InvalidOperationException'
GenericParameterPosition: 'entity.GetType().GenericParameterPosition'
threw an exception of type 'System.InvalidOperationException'
GUID: {fedaafb6-5f8e-37a0-a233-63922bdef875}
....
MemberType: TypeInfo
Module: {-fnethhd.dll}
Namespace: "MyApp.EntityExtension"
ReflectedType: null
StructLayoutAttribute:
{System.Runtime.InteropServices.StructLayoutAttribute}
TypeHandle: {System.RuntimeTypeHandle}
TypeInitializer: null
UnderlyingSystemType: {Name = "Klliik" FullName =
"MyApp.EntityExtension.Klliik"}
entityList.GetType() shows:
{Name = "List`1" FullName =
"System.Collections.Generic.List`1[[MyApp.EntityExtension.Klliik, wuxled5r,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"}
[System.RuntimeType]: {Name = "List`1" FullName =
"System.Collections.Generic.List`1[[MyApp.EntityExtension.Klliik, wuxled5r,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"}
base {System.Reflection.MemberInfo}: {Name = "List`1" FullName =
"System.Collections.Generic.List`1[[MyApp.EntityExtension.Klliik, wuxled5r,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"}
Assembly: {mscorlib, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089}
AssemblyQualifiedName:
"System.Collections.Generic.List`1[[MyApp.EntityExtension.Klliik, wuxled5r,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
Attributes: Public | Serializable | BeforeFieldInit
BaseType: {Name = "Object" FullName = "System.Object"}
ContainsGenericParameters: false
DeclaringMethod: 'entityList.GetType().DeclaringMethod' threw an
exception of type 'System.InvalidOperationException'
DeclaringType: null
FullName:
"System.Collections.Generic.List`1[[MyApp.EntityExtension.Klliik, wuxled5r,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"
GenericParameterAttributes:
'entityList.GetType().GenericParameterAttributes' threw an exception of type
'System.InvalidOperationException'
GenericParameterPosition:
'entityList.GetType().GenericParameterPosition' threw an exception of type
'System.InvalidOperationException'
GUID: {5af00c2e-048b-3ab3-8ccd-548134771d38}
...
MemberType: TypeInfo
Module: {CommonLanguageRuntimeLibrary}
Namespace: "System.Collections.Generic"
ReflectedType: null
StructLayoutAttribute:
{System.Runtime.InteropServices.StructLayoutAttribute}
TypeHandle: {System.RuntimeTypeHandle}
TypeInitializer: {Void .cctor()}
UnderlyingSystemType: {Name = "List`1" FullName =
"System.Collections.Generic.List`1[[MyApp.EntityExtension.Klliik, wuxled5r,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]"}
In summary
entity : MyApp.EntityExtension.Klliik, -fnethhd,
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
entityList member: MyApp.EntityExtension.Klliik, wuxled5r, Version=0.0.0.0,
Culture=neutral, PublicKeyToken=null
will different assembly names cause this error ?
If so, I have created only one dynamic assembly. This assembly contains both
Klliik type and GetEmptyList() function used to initialize entityList:
[Table(Name = "klliik")]
public class Klliik : MyApp.Entity.Klliik {
public Klliik() : base() { }
public Klliik(System.String Liik, System.String Nimetus, System.String
Engnimetus, System.String Finnimetus, System.String Lvlnimetus,
System.String Rusnimetus) :
base(Liik, Nimetus, Engnimetus, Finnimetus, Lvlnimetus, Rusnimetus) {
}
public static List<Klliik> GetEmptyList() {
return new List<Klliik>();
}
Why list member created from this assembly has different module name and
type created from this assembly ?
Andrus.