-
Notifications
You must be signed in to change notification settings - Fork 0
/
load-assembly.ps1
39 lines (36 loc) · 1.43 KB
/
load-assembly.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
################################################################################
## load-assembly.msh
##
## Loads a given assembly by a more friendly name, while still using the strong
## binding characteristics of Assembly.Load.
##
## Assembly.LoadWithPartialName has been deprecated, as it binds only by display
## name. It's a convenient shortcut, but opens your application and script, and
## environment to all sorts of reliability issues, including:
## backwards incompatibility, forwards incompatibility, breaking changes,
## and subtle assembly dependency problems.
##
################################################################################
param([string] $assemblyName)
## Our assembly name shortcuts
$assemblyMappings = (
("forms", "System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"),
("web", "System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
)
## List the assembly shortcuts we support
if(-not $assemblyName)
{
"Please specify an assembly name. Supported assemblies are: "
foreach($assembly in $assemblyMappings) { $assembly[0] }
return
}
## Load the assembly they request
## This fails with an error message if this specific assembly version can't
## be loaded.
foreach($assembly in $assemblyMappings)
{
if($assemblyName -eq $assembly[0])
{
[void] [Reflection.Assembly]::Load($assembly[1])
}
}