我正在尝试使用 RDP 客户端运行我的 .NET 应用程序,该应用程序位于我们域的网络共享中。
启动“完整”RDP 会话(即打开整个桌面)然后从.exe文件运行我的应用程序时,一切正常。
但是,当我设置与 RDP Client 相同的.exeStartup Application Path
时,我收到以下错误:
(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
当我使用影子复制文件时,我在应用程序刚刚开始时设置了一个新的 AppDomain(.exe 入口点):
<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 策略设置为完全机器信任,但我不确定这是否仍然适用于 .NET 4.0;
- 远程桌面(终端服务)服务器运行 Windows Server 2003;
编辑:
- 如果我将所有程序集复制到本地驱动器 ( C: ) 并从那里运行我的应用程序,它将正常工作。
有什么建议吗?