AppDomain.SetDynamicBase メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > AppDomain.SetDynamicBase メソッドの意味・解説 

AppDomain.SetDynamicBase メソッド

メモ : このメソッドは、互換性のために残されています。

動的に生成されファイル格納され、そのファイルへのアクセス先となる場所として、ディレクトリ パス設定します

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

<ObsoleteAttribute("AppDomain.SetDynamicBase has been deprecated.
 Please investigate the use of AppDomainSetup.DynamicBase instead. http://go.microsoft.com/fwlink/?linkid=14202")>
 _
Public Sub SetDynamicBase ( _
    path As String _
)
Dim instance As AppDomain
Dim path As String

instance.SetDynamicBase(path)
[ObsoleteAttribute("AppDomain.SetDynamicBase has been deprecated. Please investigate
 the use of AppDomainSetup.DynamicBase instead. http://go.microsoft.com/fwlink/?linkid=14202")]
 
public void SetDynamicBase (
    string path
)
[ObsoleteAttribute(L"AppDomain.SetDynamicBase has been deprecated. Please investigate
 the use of AppDomainSetup.DynamicBase instead. http://go.microsoft.com/fwlink/?linkid=14202")]
 
public:
void SetDynamicBase (
    String^ path
)
/** @attribute ObsoleteAttribute("AppDomain.SetDynamicBase has been deprecated.
 Please investigate the use of AppDomainSetup.DynamicBase instead. http://go.microsoft.com/fwlink/?linkid=14202")
 */ 
public void SetDynamicBase (
    String path
)
ObsoleteAttribute("AppDomain.SetDynamicBase has been deprecated. Please investigate
 the use of AppDomainSetup.DynamicBase instead. http://go.microsoft.com/fwlink/?linkid=14202")
 
public function SetDynamicBase (
    path : String
)

パラメータ

path

動的アセンブリ格納先となる絶対パス

例外例外
解説解説

このメソッドは、現在のインスタンス関連付けられている内部 AppDomainSetup の DynamicBase プロパティ設定します

使用例使用例
Imports System
Imports System.Reflection
Imports System.Reflection.Emit



Class ADDynamicBase
   
   ' SetDynamicBase.exe
   Overloads Shared Sub
 Main(args() As String)
      ' Create a new AppDomain.
      Dim setup As New AppDomainSetup()
      ' Need to set the application name before setting the dynamic
 base.
      setup.ApplicationName = "MyApplication"
      Dim domain As AppDomain = AppDomain.CreateDomain("MyDomain",
 Nothing, setup)
      
      ' Tell the domain to search for assemblies in DynamicAssemblyDir.
      domain.SetDynamicBase("C:\DynamicAssemblyDir")
      
      ' Note that the actual dynamic directory has the form
      ' <DynamicBase>\<number>\<ApplicationName>,
 rather than
      ' simply <DynamicBase>.
      Dim dynamicDir As [String] = domain.DynamicDirectory
      ' The AssemblyBuilder won't create this directory automatically.
      If Not System.IO.Directory.Exists(dynamicDir)
 Then
         System.IO.Directory.CreateDirectory(dynamicDir)
      End If
      
      ' Define the dynamic assembly.
      Dim asmName As New
 AssemblyName()
      asmName.Name = "DynamicHelloWorld"
      Dim asm As AssemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(asmName,
 AssemblyBuilderAccess.Save, dynamicDir)
      
      ' Define a dynamic module in the assembly.
      Dim [mod] As ModuleBuilder
      [mod] = asm.DefineDynamicModule("DynamicHelloWorld",
 "DynamicHelloWorld.dll")
      
      ' Define the "HelloWorld" type in the module.
      Dim typ As TypeBuilder = [mod].DefineType("HelloWorld",
 TypeAttributes.Public)
      
      ' Define the "SayHello" method.
      Dim meth As MethodBuilder = typ.DefineMethod("SayHello",
 MethodAttributes.Public, Nothing, Nothing)
      Dim il As ILGenerator = meth.GetILGenerator()
      il.EmitWriteLine("Hello World!")
      il.Emit(OpCodes.Ret)
      
      ' Complete the HelloWorld type.
      typ.CreateType()
      
      ' Save the assembly to the dynamic assembly directory.
      asm.Save("DynamicHelloWorld.dll")
      
      ' Launch MyExecutable.exe, which will load DynamicHelloWorld.dll.
      domain.ExecuteAssembly("MyExecutable.exe")
   End Sub 'Main
End Class 'ADDynamicBase
using System;
using System.Reflection;
using System.Reflection.Emit;

namespace AppDomainSnippets
{
    class ADDynamicBase
    {
        // SetDynamicBase.exe
        static void Main(string[]
 args)
        {
            // Create a new AppDomain.
            AppDomainSetup setup = new AppDomainSetup();
            // Need to set the application name before setting the dynamic
 base.
            setup.ApplicationName = "MyApplication";
            AppDomain domain = AppDomain.CreateDomain("MyDomain", null,
 setup);

            // Tell the domain to search for assemblies in DynamicAssemblyDir.
            domain.SetDynamicBase("C:\\DynamicAssemblyDir");
            
            // Note that the actual dynamic directory has the form
            // <DynamicBase>\<number>\<ApplicationName>,
 rather than
            // simply <DynamicBase>.
            String dynamicDir = domain.DynamicDirectory;
            // The AssemblyBuilder won't create this directory automatically.
            if(!System.IO.Directory.Exists(dynamicDir))
            {
                System.IO.Directory.CreateDirectory(dynamicDir);
            }

            // Define the dynamic assembly.
            AssemblyName asmName = new AssemblyName();
            asmName.Name = "DynamicHelloWorld";
            AssemblyBuilder asm = AppDomain.CurrentDomain.DefineDynamicAssembly
                (asmName, AssemblyBuilderAccess.Save, dynamicDir);

            // Define a dynamic module in the assembly.
            ModuleBuilder mod;
            mod = asm.DefineDynamicModule
                ("DynamicHelloWorld", "DynamicHelloWorld.dll");

            // Define the "HelloWorld" type in the module.
            TypeBuilder typ = mod.DefineType
                ("HelloWorld", TypeAttributes.Public);

            // Define the "SayHello" method.
            MethodBuilder meth = typ.DefineMethod
                ("SayHello", MethodAttributes.Public, null,
 null);
            ILGenerator il = meth.GetILGenerator();
            il.EmitWriteLine("Hello World!");
            il.Emit(OpCodes.Ret);

            // Complete the HelloWorld type.
            typ.CreateType();
            
            // Save the assembly to the dynamic assembly directory.
            asm.Save("DynamicHelloWorld.dll");

            // Launch MyExecutable.exe, which will load DynamicHelloWorld.dll.
            domain.ExecuteAssembly("MyExecutable.exe");
        }
    }
}
using namespace System;
using namespace System::Reflection;
using namespace System::Reflection::Emit;

// SetDynamicBase.exe
int main()
{
   array<String^>^args = Environment::GetCommandLineArgs();
   
   // Create a new AppDomain.
   AppDomainSetup^ setup = gcnew AppDomainSetup;
   
   // Need to set the application name before setting the dynamic base.
   setup->ApplicationName = "MyApplication";
   AppDomain^ domain = AppDomain::CreateDomain( "MyDomain", nullptr, setup
 );
   
   // Tell the domain to search for assemblies in DynamicAssemblyDir.
   domain->SetDynamicBase( "C:\\DynamicAssemblyDir" );
   
   // Note that the actual dynamic directory has the form
   // <DynamicBase>\<number>\<ApplicationName>, rather
 than
   // simply <DynamicBase>.
   String^ dynamicDir = domain->DynamicDirectory;
   
   // The AssemblyBuilder won't create this directory automatically.
   if (  !System::IO::Directory::Exists( dynamicDir ) )
   {
      System::IO::Directory::CreateDirectory( dynamicDir );
   }

   
   // Define the dynamic assembly.
   AssemblyName^ asmName = gcnew AssemblyName;
   asmName->Name = "DynamicHelloWorld";
   AssemblyBuilder^ asmb = AppDomain::CurrentDomain->DefineDynamicAssembly( asmName,
 AssemblyBuilderAccess::Save, dynamicDir );
   
   // Define a dynamic module in the assembly.
   ModuleBuilder^ mod;
   mod = asmb->DefineDynamicModule( "DynamicHelloWorld", "DynamicHelloWorld.dll"
 );
   
   // Define the S"HelloWorld" type in the module.
   TypeBuilder^ typ = mod->DefineType( "HelloWorld", TypeAttributes::Public
 );
   
   // Define the S"SayHello" method.
   MethodBuilder^ meth = typ->DefineMethod( "SayHello", MethodAttributes::Public,
 nullptr, nullptr );
   ILGenerator^ il = meth->GetILGenerator();
   il->EmitWriteLine( "Hello World!" );
   il->Emit( OpCodes::Ret );
   
   // Complete the HelloWorld type.
   typ->CreateType();
   
   // Save the assembly to the dynamic assembly directory.
   asmb->Save( "DynamicHelloWorld.dll" );
   
   // Launch MyExecutable.exe, which will load DynamicHelloWorld.dll.
   domain->ExecuteAssembly( "MyExecutable.exe" );
}

.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

AppDomain.SetDynamicBase メソッドのお隣キーワード
検索ランキング

   

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



AppDomain.SetDynamicBase メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS