Pages

Wednesday 8 August 2012

WHY MY ANONYMOUS TYPE CANNOT BE IDENTIFIED AS SAME TYPE IN ANOTHER ASSEMBLY?



WHY MY ANONYMOUS TYPE CANNOT BE IDENTIFIED AS SAME TYPE IN ANOTHER ASSEMBLY?

When we return an anonymous type from different assembly, assembly creates a different identification for the specific type
For e.g. CalledClass [In CalledAssembly which has customerDetail type will have different identification from the customerDetail type in the calling class].

Using reflection we can access anonymous type from another assembly but not suggestible which make your assemblies tightly coupled and maintainability will be too complex.
Reference for access anonymous from different assemblies:
http://blogsprajeesh.blogspot.com/2008/05/accessing-anonymous-types-from.html

Workarounds to access types across assemblies:

1. Using dynamic objects

Caveats:

Option strict should be OFF in VB.NET

2. Using Tuples
References:
http://msdn.microsoft.com/en-us/library/bb384767.aspx

No comments:

Post a Comment