HTML 페이지 (IE7)에 포함 된 .Net 2.0 액티브 X 컨트롤이 있습니다. javascript를 사용하여 속성을 수정하고 메서드를 호출합니다. 이 모든 것은 Activator.CreateInstance (type)를 사용하여 클래스를 인스턴스화하는 메소드를 호출하기 전까지는 괜찮습니다. 다음 메시지가 나타납니다.인트라넷 영역에서 클래스를 인스턴스화 할 때 보안 문제가 발생합니다.
System.Reflection.TargetInvocationException : 예외가 호출 대상에 의해 처리되었습니다. ---> System.Security.SecurityException : 요청이 실패했습니다.
..
..
이었다 실패 동작은 :
실패한 첫 번째 권한 유형 InheritanceDemand이었다 System.Security.PermissionSet
실패 어셈블리의 영역이었다 : 인트라넷
인스턴스화하려고하는 클래스는 parm-less public 생성자이며, 내가 읽은 것으로부터 어쨌든 공용 유형의 리플렉션을 사용하면 문제가 없어야합니다.
Microsoft .NET Framework 구성 유틸리티를 사용하여 인트라넷 트러스트를 전체로 수정하여 임시 수정을 수행했습니다. here을 참조하십시오.
프레임 워크를 구성하지 않아도되도록 메소드, 클래스 또는 어셈블리를 어떻게 수정할 수 있습니까?
몇 가지 추가 포인트 : ActiveX 컨트롤 닷넷 2
- 내가 반사 권한을 부여에 대한 방해 아니에요
- 이름이 강하지 않다.
감사
업데이트
그것은이 문제를 일으키는 반사하지 않았다 밝혀, 그것은 FileIOPermission에 보안 예외를 던졌다 TypeDescriptor.GetAttributes를 호출했다. 나는 다음과 같은 코드를 사용하여이 문제를 해결했습니다 : 내 어셈블리의 강력한 이름에 할당 된 코드 그룹을 설정하고 완전 신뢰로 설정 권한을 설정하면 이제
Dim temp As New Security.Permissions.FileIOPermission(Security.Permissions.PermissionState.Unrestricted)
temp.Assert()
// Get attributes
System.Security.CodeAccessPermission.RevertAssert()
는 모든 것이 괜찮습니다.
그러나 미세 조정할 수 없습니다. FullTrust이거나 예외가 발생했습니다 (아래 참조). 심지어는 권한 집합이 작동하지 않습니다.
예외 :
System.Security.SecurityException: Request failed.
at System.Reflection.CustomAttribute._CreateCaObject(Void* pModule, Void* pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)
at System.Reflection.CustomAttribute.CreateCaObject(Module module, RuntimeMethodHandle ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)
at System.Reflection.CustomAttribute.GetCustomAttributes(Module decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
at System.RuntimeType.GetCustomAttributes(Type attributeType, Boolean inherit)
at System.ComponentModel.ReflectTypeDescriptionProvider.ReflectGetAttributes(Type type)
at System.ComponentModel.ReflectTypeDescriptionProvider.ReflectedTypeData.GetAttributes()
at System.ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetAttributes()
at System.ComponentModel.TypeDescriptor.GetAttributes(Object component, Boolean noCustomTypeDesc)
at System.ComponentModel.TypeDescriptor.GetAttributes(Object component)
... GetAttributes
...
The action that failed was: InheritanceDemand
The type of the first permission that failed was: System.Security.PermissionSet
The Zone of the assembly that failed was: Intranet
흥미 롭습니다. 의심이 옳았고 정상적인 인스턴스 생성도 실패했습니다. 그것은 FileIOPermission 보안 예외를 던지는 TypeDescriptor.GetAttributes에 대한 호출과 관련이 있습니다. 더 자세히 조사해 보겠습니다 ... – Jules
지금까지의 위치를 보여주기 위해 내 게시물에 대한 업데이트를 추가했습니다. – Jules
http://weblogs.asp.net/whaggard/archive/2008/01/14/issues-with-the-xmlserializer-in-medium-trust-에서 설명한 것과 비슷한 문제가있는 것 같습니다. environments.aspx. 어떤 속성으로 인해 문제가 발생하는지 잘 모르겠 으면 Reflector (http://www.reflector.net/)의 유형 정의를 살펴 보시기 바랍니다. –