WPF WebBrowser 개체의 전용 속성 값을 가져 오려고합니다. 디버거에서 null이 아닌 값이 있음을 알 수 있습니다.PropertyInfo.GetProperty가 없어야 할 때 null을 반환합니다.
PropertyInfo activeXProp = Browser.GetType().GetProperty("ActiveXInstance", BindingFlags.Instance | BindingFlags.NonPublic);
object activeX = activeXProp.GetValue(Browser, null); // here I get null for the activeX value
activeX.GetType().GetProperty("Silent").SetValue(activeX, true); // and here it crashes for calling a method on a null reference...
내 생각에 적절한 방식으로 리플렉션을 사용하지 않지만이 경우 적절한 방법은 무엇입니까? 프로젝트는 .NET 4.6.1 및 Windows 10에서 실행되는 WPF 프로젝트입니다. 관리자 권한으로 실행 (프로젝트에 매니페스트 파일 추가)했지만 아무런 효과가 없습니다.
'activeX'가'null'입니까? 나에게 널주지 않는다. –
시험해 주셔서 감사합니다. 불행히도 그것은 정말로 나에게 null 값을줍니다. 다음은 전체 프로젝트입니다. https://github.com/zskolbay/WpfBrowserTest – Bedford
github에서 코드를 테스트 한 결과,'activeX'는 null이 아닙니다. 다음 행에서만 예외가 발생합니다. –