Hello Angel, Apparently this is not going to be the problem I originally anticipated. Perhaps I should explain a little bit more about the context where I will be using this. This is to be part of an ASP.NET application where the enums need to be resolved, by an expression builder, during the page's compilation.
I need to do some more checking to eliminate any silly mistakes, but it appears that referenced assemblies are already pre-loaded. Actually, I was a little bit surprised by this and I have to make certain that this is always the case. Anyone know if ASP.NET loads all referenced assemblies on start-up? In my test I found this to be so. I defined an assembly containing a single enum, added this as a reference, and when I enumerated the loaded assemblies it was available. The enum was not referenced at all in the application. Ideally I would like to hook into the build process and somehow defer the type resolution to the compiler. So, for instance, if the page has the following directive <@ Import namespace="Company.Product"> I could still resolve the type "Option.One", but maybe I am asking for too much. Fernando Tubio ----- Original Message ----- From: "Angel "Java" Lopez" <[EMAIL PROTECTED]> Sent: Friday, July 14, 2006 12:04 PM Subject: Re: Convert string enum constant to the underlying value Hi people! Yes, Fernando, sometimes, you need to load the assembly if it's not loaded yet, as in your code. I usually call .GetReferencedAssemblies() on each loaded assembly, then I load manually each one that it's not loaded (I don't know to check how an assembly is loaded or not, then I consult the complete list of loaded assembly from AppDomain.CurrentDomain.GetAssemblies). Angel "Java" Lopez http://www.ajlopez.com/ > > The preceding code works but I wonder if there is a more direct route. For > instance, is enumerating the loaded assemblies and calling GetType on each > an appropiate mechanism to search for the enum's type? Also, I suppose the > code would fail if the enum is defined in a referenced assembly which > hasn't > been loaded yet. Are there any alternatives? Does parsing the name of the > enum's type and the constant's name by splitting the string at the last > '.' > character cover every possible case? > > Fernando Tubio > =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com
