RDP クライアントを使用して、ドメインのネットワーク共有にある .NET アプリケーションを実行しようとしています。
「完全な」RDP セッションを開始する (つまり、デスクトップ全体を開く) と、.exeファイルからアプリケーションを実行すると、すべて正常に動作します。
しかし、これと同じ.exeをStartup Application Path
RDP クライアントから設定すると、次のエラーが発生します。
(PS: スタック トレースを、自分自身がより重要であると判断した呼び出しにクリップしました)
System.TypeInitializationException: The type initializer for 'NHibernate.Cfg.Environment' threw an exception. ---> System.ArgumentException: Incorrect Parameter. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
at System.Security.Policy.PEFileEvidenceFactory.GetLocationEvidence(SafePEFileHandle peFile, SecurityZone& zone, StringHandleOnStack retUrl)
(...)
at System.AppDomain.get_Evidence()
(...)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at NHibernate.Cfg.Environment.LoadGlobalPropertiesFromAppConfig() in p:\nhibernate-core\src\NHibernate\Cfg\Environment.cs:line 212
at NHibernate.Cfg.Environment..cctor() in p:\nhibernate-core\src\NHibernate\Cfg\Environment.cs:line 198
シャドウ コピーされたファイルを操作するため、アプリケーションの開始直後 (.exe エントリ ポイント) に新しい AppDomain を設定します。
<STAThread()>
Public Sub Main()
Try
Dim currentDirectory As DirectoryInfo = New DirectoryInfo(Directory.GetCurrentDirectory)
Dim runtimeDirectory As DirectoryInfo = New FileInfo(Assembly.GetExecutingAssembly.Location).Directory
Dim appDomainStartupSetup As New AppDomainSetup
appDomainStartupSetup.ApplicationBase = currentDirectory.FullName
appDomainStartupSetup.ShadowCopyFiles = "true"
Dim appDomainStartup As AppDomain = AppDomain.CreateDomain("StartupAppDomain", Nothing, appDomainStartupSetup)
Dim entrypointLoader As LoadBaseFiles = appDomainStartup.CreateInstanceFromAndUnwrap(Assembly.GetExecutingAssembly.CodeBase, "MyClass.LoadBaseFiles")
entrypointLoader.RuntimeDir = runtimeDirectory.FullName ' Setup the 'entry-point' object
entrypointLoader.StartupEntryPoint() ' Starts the Application
Catch ex As Exception
' Error Handling Here
End Try
End Sub
Public Class LoadBaseFiles
Inherits MarshalByRefObject
' Startup stuff here...
End Class
より詳しい情報
- 私の ApplicationEntryPoint.exe.config ファイルの内容;
- CAS ポリシーを Full Machine Trust に設定しましたが、これが .NET 4.0 に適用されるかどうかはわかりません。
- リモート デスクトップ (ターミナル サービス) サーバーは Windows Server 2003 を実行します。
編集:
- すべてのアセンブリをローカル ドライブ ( C: ) にコピーし、そこからアプリケーションを実行すると、正常に動作します。
何かアドバイスはありますか?