DLL无法在远程位置找到AppConfig文件

时间:2013-09-30 14:45:53

标签: c# dll

这个问题来自"Cannot initialize public static class when the DLL is placed in a remote server"起初我无法在Powershell上获得详细的堆栈跟踪,但后来当我找到一种方法时,我意识到这个问题可能不准确,可能是一个新问题。

我在网络共享文件夹中有一个DLL,在使用Import-Module将其导入PowerShell后,调用DLL的方法会显示以下错误:

  

Configuration.AppConfiguration的类型初始值设定项引发了异常

     

TypeName:InsightDSL.DSLConfiguration.AppConfiguration

     

消息:“InsightDSL.DSLConfiguration.AppConfiguration”的类型初始化程序引发了异常。

     

数据:{}

     

InnerException:System.Configuration.ConfigurationErrorsException:加载配置文件时出错:参数'exePath'无效。                    参数名称:exePath ---> System.ArgumentException:参数'exePath'无效。                    参数名称:exePath                       在System.Configuration.ClientConfigPaths..ctor(String exePath,Boolean includeUserConfig)                       在System.Configuration.ClientConfigurationHost.get_ConfigPaths()                       在System.Configuration.ClientConfigurationHost.GetStreamName(String configPath)                       在System.Configuration.BaseConfigurationRecord.InitConfigFromFile()                       ---内部异常堆栈跟踪结束---                       在System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)                       在System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)                       在System.Configuration.Configuration..ctor(String locationSubPath,Type typeConfigHost,Object [] hostInitConfigurationParams)                       在System.Configuration.ClientConfigurationHost.OpenExeConfiguration(ConfigurationFileMap fileMap,Boolean isMachine,                    ConfigurationUserLevel userLevel,String exePath)                       在InsightDSL.DSLConfiguration.AppConfiguration..cctor()

     

TargetSite:Int32 get_TimeoutValue()

     

StackTrace:在InsightDSL.DSLConfiguration.AppConfiguration.get_TimeoutValue()                       在InsightDSL.SetInsightConnection.SetEnvironment()                       在InsightDSL.SetInsightConnection.ProcessRecord()                       在System.Management.Automation.CommandProcessor.ProcessRecord()

该类抛出异常:

namespace Configuration
public static class AppConfiguration
{
    private static Configuration Configuration = ConfigurationManager.OpenExeConfiguration(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath);
    public static string name {...}
    public static int timeout {...}
}

如果我将DLL复制到我的本地文件夹,则不会发生错误并且一切正常,但是在该远程位置,它只是不起作用。

0 个答案:

没有答案