다른 어셈블리에있는 CommandDrawing
클래스의 인스턴스를 동적으로 만들려고합니다. CommandDrawing
클래스 기본 생성자에는 동일한 어셈블리의 다른 클래스에있는 정적 메서드에 대한 호출이 포함되어 있습니다. 동적 클래스는 만들었지 만 그것은 예외 전복 생성자에서 정적 메서드 호출을 실행 할려고하면된다다른 정적 클래스 메서드를 호출하는 생성자를 사용하여 클래스를 동적으로 만듭니다.
Exception has been thrown by the target of an invocation. TypeInitializeException`The type initializer for threw an exception.
내가 두 클래스에서 어떻게 그렇다면로드해야합니까?
정적 메서드 호출하지있을 때 내가 전에 성공적으로 사용하고 작동 한 클래스를 만들려면 아래 코드를 사용
Assembly assemblyCommandDrawing = System.Reflection.Assembly.LoadFile(@"D:\ManifoldInspections.dll");
Type typeCommandDrawing = assemblyCommandDrawing.GetType("InspectionDetails.CommandDrawing");
object cmd = System.Activator.CreateInstance (typeCommandDrawing, new object[] { drawing, DrawingBaseDetail });
CommandDrawing
기본 생성자는 다음과 같다 - UtilityMapControl.SetupDrawingTableTemplate
주의는 정적 방법 내가 전화를 걸고 여기에 넘어집니다 :
public CommandDrawing(Manifold.Interop.Drawing p_Drawing, InspectionDetails.DrawingBaseDetail p_ClassDetailTemplate)
{
this.Drawing = p_Drawing;
//this.ClassDetailTemplate = p_ClassDetailTemplate.GetType();
this.ClassDetailTemplate = p_ClassDetailTemplate;
ManifoldInspections.Utility.UtilityMapControl.SetupDrawingTableTemplate(this.Drawing, p_ClassDetailTemplate);
}
동적 클래스를 생성하는 코드를 제공 할 수 있습니까? – ivowiblo
내부 예외가 있습니까? 그렇다면 무엇입니까? 명시 적으로 두 클래스를 모두로드 할 필요는 없습니다. –
ivowiblo - 죄송합니다. 저는 클래스가 아닌 클래스의 인스턴스를 동적으로 생성하고 있습니다. – gisWeeper