tags:

views:

561

answers:

2

I need to dynamically get the list of Controls in the PresentationFramework assembly. For now, I can load the assembly with this piece of code:

    var asmName = new AssemblyName("PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
var asm = Assembly.Load(asmName);

However, if in the future the framework is updated to higher version, the above code won't be able to pick up the new assembly. Please show me how to do it the right way. Many thanks.

+1  A: 

I don't think that there is a way to automatically get the latest version of an assembly in the GAC, since that could lead to the whole "DLL Hell" problem all over again. Strong-named assemblies, which all assemblies in the GAC are required to be, include their version number in their name to ensure that you are loading exactly the version you expect. This will prevent a newer version of the assembly from breaking your application.

Andy
That's what I'm thinking too. Thanks Andy.
mqbt
A: 

It's depreciated but you can use:

Assembly.LoadWithPartialName("PresentationFramework");
scmccart