Assembly.LoadFrom メソッド
アセンブリを読み込みます。
オーバーロードの一覧
ファイル名またはパスを指定してアセンブリを読み込みます。
.NET Compact Framework でもサポート。
[Visual Basic] Overloads Public Shared Function LoadFrom(String) As Assembly
[JScript] public static function LoadFrom(String) : Assembly;
ファイル名またはパスを指定してアセンブリを読み込み、セキュリティ証拠を提供します。
[Visual Basic] Overloads Public Shared Function LoadFrom(String, Evidence) As Assembly
[C++] public: static Assembly* LoadFrom(String*, Evidence*);
[JScript] public static function LoadFrom(String, Evidence) : Assembly;
ファイル名またはパス、セキュリティ証拠のハッシュ値、ハッシュ アルゴリズムを指定してアセンブリを読み込みます。
[Visual Basic] Overloads Public Shared Function LoadFrom(String, Evidence, Byte(), AssemblyHashAlgorithm) As Assembly
[C#] public static Assembly LoadFrom(string, Evidence, byte[], AssemblyHashAlgorithm);
[C++] public: static Assembly* LoadFrom(String*, Evidence*, unsigned char __gc[], AssemblyHashAlgorithm);
[JScript] public static function LoadFrom(String, Evidence, Byte[], AssemblyHashAlgorithm) : Assembly;
使用例
ファイル名またはパスを指定してアセンブリを読み込む例を次に示します。
Dim SampleAssembly As [Assembly]
SampleAssembly = [Assembly].LoadFrom("c:\Sample.Assembly.dll")
' Obtain a reference to a method known to exist in assembly.
Dim Method As MethodInfo = SampleAssembly.GetTypes()(0).GetMethod("Method1")
' Obtain a reference to the parameters collection of the MethodInfo instance.
Dim Params As ParameterInfo() = Method.GetParameters()
' Display information about method parameters.
' Param = sParam1
' Type = System.String
' Position = 0
' Optional=False
Dim Param As ParameterInfo
For Each Param In Params
Console.WriteLine(("Param=" + Param.Name.ToString()))
Console.WriteLine((" Type=" + Param.ParameterType.ToString()))
Console.WriteLine((" Position=" + Param.Position.ToString()))
Console.WriteLine((" Optional=" + Param.IsOptional.ToString()))
Next Param
[C#]
Assembly SampleAssembly;
SampleAssembly = Assembly.LoadFrom("c:\\Sample.Assembly.dll");
// Obtain a reference to a method known to exist in assembly.
MethodInfo Method = SampleAssembly.GetTypes()[0].GetMethod("Method1");
// Obtain a reference to the parameters collection of the MethodInfo instance.
ParameterInfo[] Params = Method.GetParameters();
// Display information about method parameters.
// Param = sParam1
// Type = System.String
// Position = 0
// Optional=False
foreach (ParameterInfo Param in Params)
{
Console.WriteLine("Param=" + Param.Name.ToString());
Console.WriteLine(" Type=" + Param.ParameterType.ToString());
Console.WriteLine(" Position=" + Param.Position.ToString());
Console.WriteLine(" Optional=" + Param.IsOptional.ToString());
}
[C++]
Assembly* SampleAssembly;
SampleAssembly = Assembly::LoadFrom(S"c:\\Sample.Assembly.dll");
// Obtain a reference to a method known to exist in assembly.
MethodInfo* Method = SampleAssembly->GetTypes()[0]->GetMethod(S"Method1");
// Obtain a reference to the parameters collection of the MethodInfo instance.
ParameterInfo* Params[] = Method->GetParameters();
// Display information about method parameters.
// Param = sParam1
// Type = System::String
// Position = 0
// Optional=False
IEnumerator* myEnum = Params->GetEnumerator();
while (myEnum->MoveNext()) {
ParameterInfo* Param = __try_cast<ParameterInfo*>(myEnum->Current);
Console::WriteLine(S"Param= {0}", Param->Name);
Console::WriteLine(S" Type= {0}", Param->ParameterType);
Console::WriteLine(S" Position= {0}", __box(Param->Position));
Console::WriteLine(S" Optional= {0}", __box(Param->IsOptional));
}
[JScript]
var SampleAssembly : Assembly;
SampleAssembly = Assembly.LoadFrom("c:\\Sample.Assembly.dll");
// Obtain a reference to a method known to exist in assembly.
var Method : MethodInfo = SampleAssembly.GetTypes()[0].GetMethod("Method1");
// Obtain a reference to the parameters collection of the MethodInfo instance.
var Params : ParameterInfo[] = Method.GetParameters();
// Display information about method parameters.
// Param = sParam1
// Type = System.String
// Position = 0
// Optional=False
for (var i : int in Params){
var Param : ParameterInfo = Params[i];
Console.WriteLine("Param=" + Param.Name.ToString());
Console.WriteLine(" Type=" + Param.ParameterType.ToString());
Console.WriteLine(" Position=" + Param.Position.ToString());
Console.WriteLine(" Optional=" + Param.IsOptional.ToString());
}