Assembly クラスとは? わかりやすく解説

Assembly クラス

Assembly定義します。このアセンブリ再利用でき、バージョン管理可能で自己記述型の共通言語ランタイム アプリケーションビルド ブロックです。

名前空間: System.Reflection
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<SerializableAttribute> _
<ClassInterfaceAttribute(ClassInterfaceType.None)> _
<ComVisibleAttribute(True)> _
Public Class Assembly
    Implements _Assembly, IEvidenceFactory, ICustomAttributeProvider,
 ISerializable
[SerializableAttribute] 
[ClassInterfaceAttribute(ClassInterfaceType.None)] 
[ComVisibleAttribute(true)] 
public class Assembly : _Assembly, IEvidenceFactory,
 ICustomAttributeProvider, 
    ISerializable
[SerializableAttribute] 
[ClassInterfaceAttribute(ClassInterfaceType::None)] 
[ComVisibleAttribute(true)] 
public ref class Assembly : _Assembly, IEvidenceFactory,
 ICustomAttributeProvider, 
    ISerializable
/** @attribute SerializableAttribute() */ 
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.None) */ 
/** @attribute ComVisibleAttribute(true) */ 
public class Assembly implements _Assembly,
 IEvidenceFactory, 
    ICustomAttributeProvider, ISerializable
SerializableAttribute 
ClassInterfaceAttribute(ClassInterfaceType.None) 
ComVisibleAttribute(true) 
public class Assembly implements _Assembly,
 IEvidenceFactory, 
    ICustomAttributeProvider, ISerializable
解説解説
使用例使用例

アセンブリ内のメソッドについて、メソッド シグネチャ列挙するコード例次に示します

' LoadInvoke loads MyAssembly.dll and lists the method
' information for each method. After compiling this class,
' run LoadInvoke.exe with the DisplayName for the assembly,
' as shown here:
' LoadInvoke MyAssembly
Imports System
Imports System.Reflection
Imports System.Security.Permissions

Public Class LoadInvoke

    <PermissionSetAttribute(SecurityAction.Demand, Name:="FullTrust")>
 _
    Public Shared Sub Main(ByVal
 args() As String)
        Dim a As [Assembly] = [Assembly].Load(args(0))
        Dim mytypes As Type() = a.GetTypes()
        Dim flags As BindingFlags = BindingFlags.NonPublic
 Or BindingFlags.Public Or BindingFlags.Static
 Or _
            BindingFlags.Instance Or BindingFlags.DeclaredOnly

        Dim t As Type
        For Each t In mytypes
            Dim mi As MethodInfo() = t.GetMethods(flags)
            Dim obj As [Object] = Activator.CreateInstance(t)

            Dim m As MethodInfo
            For Each m In
 mi
                ' Instead of invoking the methods,
                ' it's safer to initially just list them.
                Console.WriteLine(m)
            Next m
        Next t
    End Sub 
End Class 
// LoadInvoke loads MyAssembly.dll and lists the method
// information for each method. After compiling this class,
// run LoadInvoke.exe with the DisplayName for the assembly,
// as shown here:
// LoadInvoke MyAssembly

using System;
using System.Reflection;
using System.Security.Permissions;

public class LoadInvoke
{
    [PermissionSetAttribute(SecurityAction.Demand, Name="FullTrust")]
    public static void Main(string[]
 args)
    {
        Assembly a = Assembly.Load(args[0]);
        Type[] mytypes = a.GetTypes();
        BindingFlags flags = (BindingFlags.NonPublic | BindingFlags.Public |
            BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly);

        foreach(Type t in mytypes)
        {
            MethodInfo[] mi = t.GetMethods(flags);
            Object obj = Activator.CreateInstance(t);

            foreach(MethodInfo m in mi)
            {
                // Instead of invoking the methods,
                // it's safer to initially just list them.
                Console.WriteLine(m);
            }
        }
    }
}
' Use this class with the LoadInvoke program.
' Compile this class using vbc /t:library MyAssembly.vb
' to obtain MyAssembly.dll.
Imports System
Imports Microsoft.VisualBasic

Public Class MyAssembly
    Public Sub MyMethod1()
        Console.WriteLine("Invoking MyAssembly.MyMethod1")
    End Sub 'MyMethod1
End Class 'MyAssembly
// Use this class with the LoadInvoke program.
// Compile this class using "csc /t:library MyAssembly.cs"
// to build MyAssembly.dll.
using System;

public class MyAssembly
{
    public void MyMethod1()
    {
        Console.WriteLine("This is MyMethod1");
    }
    public void MyMethod2()
    {
        Console.WriteLine("This is MyMethod2");
    }
    public void MyMethod3()
    {
        Console.WriteLine("This is MyMethod3");
    }
}
// Use this class with the LoadInvoke program.
// Compile this class using csc /t:library MyAssembly.cs
// to obtain MyAssembly.dll.
using namespace System;
public ref class MyAssembly
{
public:
   void MyMethod1()
   {
      Console::WriteLine( "Invoking MyAssembly.MyMethod1" );
   }

};

継承階層継承階層
System.Object
  System.Reflection.Assembly
     System.Reflection.Emit.AssemblyBuilder
スレッド セーフスレッド セーフ

この型は、マルチスレッド操作に対して安全です。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Assembly クラス」の関連用語

Assembly クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Assembly クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS