Hi Fabian, First of all, thank you for uncovering a deficiency in IL Assembler -- it doesn't have syntax to specify a generic method in ldtoken instruction, only an instantiation of a generic method. The following syntax should be supported (but isn't): ldtoken method void PreloadMethodInfo.Program::Generic<[1]>()
Second of all, please accept my sincere apologies for this screw-up. Looking back, I'm puzzled just how could I miss this. I'm going to try pushing the necessary fix into next service pack, but I can't promise any concrete ETA. Thanks, Serge -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Fabian Schmied Sent: Tuesday, April 24, 2007 12:32 AM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] How to do ldtoken on generic method specs in IL Hi Serge, > The IL error you get is due to usage of !!0 outside of generic instantiation > context. You simply don't have type parameter #0 in this context. > > Try the following: > ldtoken method void PreloadMethodInfo.Program::Generic<class .this>() Thanks for your answer, it works. I can't say I understand why it loads a runtime handle for the uninstantiated Generic<T> when I specify the instantiated Generic<PreloadMethodInfo.Program>, but in this sample, it does exactly what I need. However, as I'm trying to generalize this code to loading a handle for arbitrary generic methods, it's not always so simple. If there are interface constraints on the method's type parameters, it's not as easy to find a valid instantiation; "class .this" will not always work. If I understand correctly, I can only load handles to generic methods of which I can name an instantiation at the time of token loading. Is this correct, or is there another way? Best regards, Fabian =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com