Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What should I use instead of LoadWithPartialName()?

Tags:

I'm loading an assembly with LoadWithPartialName(), but VS tells me that it's obsolete and to use Load() instead. However, I can't find any convenient overload.

There is a Load(string) with asks for a "full-name" which, if I understood correctly the MSDN docs, includes things like the version number.

There is also a Load (string, Evidence) which accepts a "Display name". The problem is I don't have the slightest idea what the "Display Name" is, as the "Partial Name" I was using with the first function doesn't seem to work.

So, how should it be done?

like image 830
raven Avatar asked Jul 14 '09 12:07

raven


People also ask

What is reflection assembly PowerShell?

Reflection. Assembly class. This means that you can pass it to the Get-Member Windows PowerShell cmdlet and see what methods, properties and events are available.


1 Answers

Here's what I did. I am loading "Microsoft.AnalysisServices" into PowerShell as my example.

  1. Open the GAC folder that has the assembly. It can be any one of the following:
    • C:\Windows\Microsoft.NET\assembly\GAC_32
    • C:\Windows\Microsoft.NET\assembly\GAC_64
    • C:\Windows\Microsoft.NET\assembly\GAC_MSIL
  2. In that folder, open the folder for your assembly.
  3. In that folder, you will see another folder that looks like this:
    • v4.0_15.0.0.0__89845dcd8080cc91
  4. Break this down into the component parts:
    • v4.0 (I think this is the .NET version, but we don't need it here.)
    • 15.0.0.0 (This is the version you're looking for)
    • 89845dcd8080cc91 (This is the public key)
  5. Now you can create your assembly string.

    [System.Reflection.Assembly]::Load("Microsoft.AnalysisServices, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91")
    

For .NET assemblies, Culture is always neutral.

like image 156
Slogmeister Extraordinaire Avatar answered Oct 19 '22 12:10

Slogmeister Extraordinaire