0

저는 Active Directory 역할을 사용하여 winfowms 앱용으로 VB.NET과 함께 VS2012를 사용하고 있습니다. 권한없이 사용자 권한으로 프로그램을 실행하면이 양식을 시작하려고 할 때 예상되는 보안 예외가 발생합니다.외부 코드에서만 .NET 보안 예외가 발생했습니다.

I는 다음과 같다 양식을 가지고 :

<PrincipalPermission(SecurityAction.Demand, Role:=Security.Roles.ADMINISTRATORS)> _ 
<PrincipalPermission(SecurityAction.Demand, Role:=Security.Roles.CORRECTIVE_ACTION_EDITORS)> _ 
<PrincipalPermission(SecurityAction.Demand, Role:=Security.Roles.GRIEVANCE_EDITORS)> _ 
<PrincipalPermission(SecurityAction.Demand, Role:=Security.Roles.ABOLISHMENT_EDITORS)> _ 
Public Class EmployeeInformationForm 
... 
End Class 

코드에 대한 호출은 다음과 같습니다

Private Sub SendEmployeeIDToEmployeeInformationForm(ByVal ID_in As String, ByVal employeeRecord_in As String) 
    ... 
     If Not formFound Then 
      ' Create a new instance of the child form. 
      Dim ChildForm As New EmployeeInformationForm(ID_in, employeeRecord_in) ' ** throws expected security exception here** 
      Try 
       ' Make it a child of this MDI form before showing it. 
       ChildForm.MdiParent = Me.MdiParent 
     ... 
       ChildForm.Show() 
      Catch ex As Exception 
       ChildForm.Close() 
       Throw 
      End Try 
     End If 

15 후 16 시도 (또는 어쩌면 변수는 이후 "입니다 약 1 분 "?) 프로그램이 충돌합니다. 업데이트 : 어떤 종류의 입력이 나면 프로그램이 충돌합니다. 나는 허락없이 debugged the code as the user을 가지며, 던져진 예외를 포착 할 수있었습니다 - 어디에도 없었습니다. 그것은 다음과 같은 "호출 스택은 외부 코드가 포함되어 있습니다"라는 매우 이상하고, 표시

힘든 시간 양식을 닫는 데 의미하는 것
This thread is stopped with only external code frames on the call stack. External code frames are typically from framework code but can also include other optimized modules which are loaded in the target process. 

Call stack with external code 

mscorlib.dll!System.Security.Permissions.PrincipalPermission.ThrowSecurityException() 
mscorlib.dll!System.Security.Permissions.PrincipalPermission.Demand() 
mscorlib.dll!System.Security.PermissionSet.DemandNonCAS() 
[Native to Managed Transition] 
[Managed to Native Transition] 
OHRC Database.exe!OHRC_Database.EmployeeInformationForm.Dispose(Boolean disposing) 
System.dll!System.ComponentModel.Component.Finalize() 

? 아무도 왜이 예외를 던지고 말해 줄래?

답변

2

finalization 스레드에서 예외가 발생합니다 (예외 스택 추적의 Finalize() 호출이 이에 대한 힌트 임). 해당 스레드의 사용자 ID에도 올바른 권한이 없습니다. 자세한 내용 및 수정 사항은 http://msmvps.com/blogs/calinoiu/archive/2006/01/07/why-is-my-application-coughing-up-a-securityexception-after-my-code-stops-running.aspx을 참조하십시오.

HTH, 니콜

+0

그것은 * 가비지 컬렉터는 *를 제외하고 ... 많은 설명 던지고있다! – Watki02

+0

오버라이드가 필요한 Finalize() * 및 * Dispose() 둘 중 하나입니까? ... 만약에, 어느 것? – Watki02

+1

호출되는 finalizer는'System.ComponentModel.Component'에서 선언됩니다. 이미 실행 중이므로 무시해야합니다. workaround 속성을 필요로하는 유일한 방법은'EmployeeInformationForm.Dispose (Boolean disposing)'입니다. –

관련 문제