안녕하세요 런타임에 클래스를 찾고 인스턴스화하려고합니다. 어셈블리가 팩토리 객체에로드됩니다.리플렉션을 통해 런타임에 클래스를 인스턴스화합니다.
그것은이 시점
Object obj = Activator.CreateInstance(
(factory.ProxyAssembly.GetType("tempuri.org.Authorizations")));
까지 잘 작동하지만 사용할 수없는 obj
Obj.FirstName
또는 obj.LastName
그래서 적절한 기본이되는 클래스로 캐스트하려고으로 속성 이름을 얻을 수 없습니다.
하지만 아래 코드는 작동하지 않습니다.
factory.ProxyAssembly.GetType("tempuri.org.Authorizations")
.UnderlyingSystemType.BaseType a =
Activator.CreateInstance(factory.ProxyAssembly
.GetType("tempuri.org.Authorizations").UnderlyingSystemType);
도움을 주시면 감사하겠습니다. (유형)와 주조로
obj를 인증 기관에 전송 했습니까? 목표를 달성하기위한 다른 좋은 방법이있을 수 있기 때문에 정확히 무엇을하려는 것입니까? – TJHeuvel
지금까지 직접 실행 창에서 실행 중입니다. ("tempuri.org.Authorizations"). UnderlyingSystemType.BaseType a = Activator.CreateInstance (factory.ProxyAssembly.GetType ("tempuri.org.Authorizations"). UnderlyingSystemType); 표현식의 끝 예상 됨 "End of expression expected"메시지가 표시됩니다. – WorkerThread
@TJHeuvel 유형 인증에 대해 알지 못합니다. Factory.ProxyAssembly.GetType ("tempuri.org.Authorizations"). UnderlyingSystemType – WorkerThread