0

我正在尝试使用 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

更多信息

编辑:

  • 如果我将所有程序集复制到本地驱动器 ( C: ) 并从那里运行我的应用程序,它将正常工作。

有什么建议吗?

4

1 回答 1

1

看起来您缺少参数或指向不可用的资源。

a) 是否为应用程序设置了工作目录?

b) 用户登录时是否可以使用工作目录?

于 2013-05-09T20:54:48.117 回答