각 NetBeans는 자신의 AppDomains에 플러그인 (dll)을로드하는 .net WinForms 응용 프로그램을 가지고 있으며 각 dll은 domain.CreateInstanceAndUnwrap()을 사용하여 자체 AppDomain을 가져옵니다. 내가 원하는 건,이 객체들이 영원히 연결되어있을 때까지 (응용 프로그램이 멈출 때까지).
InitialLeaseTime은 5 분이지만 변경할 수있는 방법을 찾을 수 없습니다. .. 나는 원격 객체의 InitializeLifetimeService() 재정의하는 시도 : 여기MarshalByRefObject Lifetime
Public Overrides Function InitializeLifetimeService() As Object
Return Nothing
End Function
나는 Typeload-예외를 얻을이 상속 규칙을 깰 것이라고 말. 추가
<SecurityPermissionAttribute(SecurityAction.Demand, Flags:=SecurityPermissionFlag.Infrastructure)>
<SecuritySafeCritical>
아무 것도 변경되지 않습니다. 그런 다음
: 스폰서 (여기에 표시되지 않음) 어떻게 든 갱신() 메소드가 호출되지 않습니다 때문에
Dim tmpObj As Object = domain.CreateInstanceAndUnwrap(type.AssemblyName, type.TypeName)
Dim tmpRemote As tmpRemoteType = CType(tmpObj, tmpRemoteType)
Dim lifetimeService As Object = Runtime.Remoting.RemotingServices.GetLifetimeService(tmpRemote)
Dim lease As ILease = TryCast(lifetimeService, ILease)
If (lease IsNot Nothing) Then
lease.Register(_sponsor)
End If
이 그것을하지 않는다 어느 쪽도하지 않습니다.
lease.Renew(TimeSpan.FromMinutes(300))
를 호출
직접 CurrentLeaseTime을 변경하지만 임대가 아닌 InitialLeaseTime.
마지막으로 내가 실제로 임대의 시작 부분에 CurrentLeaseTime의 변화에지도 공유 속성 (정적) LeaseTime를 호출했지만, 다시 하지 5 분 종료 보인다 InitialLeaseTime, 내 원격 객체 gc'ed되고 :LifetimeServices.RenewOnCallTime = System.TimeSpan.FromMinutes(300)
어떤 도움에 감사드립니다, 들으! 그것은이 경우
var sponsor = new Sponsor(); // manages lifetime of the object in otherDomain
var target = otherDomain.CreateInstanceFromAndUnwrap(assemblyFilename, typeFullName)
as MarshalByRefObject;
var lease = target.InitializeLifetimeService() as ILease;
lease.Register(sponsor);
을 어떻게 작동하는지 여기
안녕하세요. 감사합니다. 귀하의 솔루션으로 스폰서의 Renewal() 메소드가 호출됩니다.하지만 TimeSpan.FromHours (1)를 반환 할 때가끔 작동하고 때때로 그렇지 않습니다. 나는 지금 많은 것을 실험했지만, 알아 내지 못합니다 ... btw : lease.CurrentState는 항상 "갱신"이 아닌 갱신() 내에서 "활성"입니다. – Lukas
업데이트 : 이제 작동 중입니다. 원격 객체 내에서 MarshalByRefObject로부터 상속받은 다른 객체에 대한 참조를 가졌습니다. 이 물건의 임대도 다시해야했다. – Lukas