■ 객체 구하기 예제

----------------------------------------------------------------------------------------------------

string assemblyFilePath = Path.Combine(Application.StartupPath, "Sample.Test.exe");

string targetType       = "Sample.Test.SampleControl";

 

Sample.Test.SampleControl sampleControl = GetObject(assemblyFilePath, targetType) as Sample.Test.SampleControl;

----------------------------------------------------------------------------------------------------

 

■ 객체 구하기

----------------------------------------------------------------------------------------------------

using System;

using System.Runtime.Remoting;

 

#region 객체 구하기 - GetObject(assemblyFilePath, targetType)

 

/// <summary>

/// 객체 구하기

/// </summary>

/// <param name="assemblyFilePath">어셈블리 파일명</param>

/// <param name="targetType">타겟 타입</param>

/// <returns>object</returns>

public object GetObject(string assemblyFilePath, string targetType)

{

    ObjectHandle objectHandle = Activator.CreateInstanceFrom(assemblyFilePath, targetType);

 

    return objectHandle.Unwrap();

}

 

#endregion

----------------------------------------------------------------------------------------------------

Posted by 사용자 icodebroker

댓글을 달아 주세요