|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
GetType not working on custom assemblies in .NET 2.0wth GetType and a custom class whose assembly resides in the GAC. In 1.1, we could call, for example: System.Type.GetType(""ElanHomeProject.ElanControl.ElanKeyPad.Z100, ElanHomeProject"); This work work just fine, returning the type of that particular class. Now, in 2.0, that call results in a null Type, and the call only seems to work if we make the GetType call as so: System.Type.GetType(""ElanHomeProject.ElanControl.ElanKeyPad.Z100, ElanHomeProject, Version=2.0.0.0, Culture=neutral, PublicKeyToken=f50445a37b571e16"); Additionally, a call such as: Type objType = typeof(ElanHomeProject.ElanControl.ElanKeyPad.Z100); works in 2.0, but the way our application is built, the type is passed as a string, so we HAVE to use GetType. Has anyone else had this problem? Can anyone suggest a solution where we won't have to pass the Version, Culture and PublicKeyToken? Thank you in advance! Gabe
Show quote
"Gabe Covert" <GabeCov***@discussions.microsoft.com> wrote in message You can always just examine the loaded assemblies and grab the first type news:19338DBA-A47D-4953-B401-F8AF42A9E0CA@microsoft.com... > We have just migrated to VS 2005 and .NET 2.0, and are having some > problems > wth GetType and a custom class whose assembly resides in the GAC. > > In 1.1, we could call, for example: > System.Type.GetType(""ElanHomeProject.ElanControl.ElanKeyPad.Z100, > ElanHomeProject"); > > This work work just fine, returning the type of that particular class. > > Now, in 2.0, that call results in a null Type, and the call only seems to > work if we make the GetType call as so: > > System.Type.GetType(""ElanHomeProject.ElanControl.ElanKeyPad.Z100, > ElanHomeProject, Version=2.0.0.0, Culture=neutral, > PublicKeyToken=f50445a37b571e16"); > > Additionally, a call such as: > Type objType = typeof(ElanHomeProject.ElanControl.ElanKeyPad.Z100); > > works in 2.0, but the way our application is built, the type is passed as > a > string, so we HAVE to use GetType. > > Has anyone else had this problem? Can anyone suggest a solution where we > won't have to pass the Version, Culture and PublicKeyToken? > > Thank you in advance! > with a matching name. EG static Type GetType(string name) { foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies()) { Type t = a.GetType(name); if ( t != null) return t; } return null; } David |
|||||||||||||||||||||||