代码之家  ›  专栏  ›  技术社区  ›  thmsn

控制台应用程序中的生产服务器上发生奇怪的FileNotFoundException

  •  1
  • thmsn  · 技术社区  · 16 年前

    嗨,我有一个应用程序在我的开发环境中运行良好,但在生产环境中抛出了奇怪的错误,我在我的开发机器和生产服务器上检查了.NET的版本,它们都运行3.5.30729.01。

    我得到的异常是System.IO.FileNotFoundException。

    StackTrace:

    at System.Diagnostics.FileVersionInfo.GetVersionInfo(String fileName)
    at System.Configuration.ClientConfigPaths.SetNamesAndVersion(String applicationFilename, Assembly exeAssembly, Boolean isHttp)
    at System.Configuration.ClientConfigPaths..ctor(String exePath, Boolean includeUserConfig)
    at System.Configuration.ClientConfigPaths.GetPaths(String exePath, Boolean includeUserConfig)
    at System.Configuration.ClientConfigurationHost.get_ConfigPaths()
    at System.Configuration.ClientConfigurationHost.RequireCompleteInit(IInternalConfigRecord record)
    at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
    at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
    at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
    at System.Configuration.ConfigurationManager.GetSection(String sectionName)
    at System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)
    at System.DirectoryServices.SearchResultCollection.ResultsEnumerator..ctor(SearchResultCollection results, String parentUserName, String parentPassword, AuthenticationTypes parentAuthenticationType)
    at System.DirectoryServices.SearchResultCollection.GetEnumerator()
    at System.DirectoryServices.DirectorySearcher.FindOne()
    

    昨天错误刚刚消失,今天又出现了。我尝试在调用后在system.directoryservices.directorysearcher.findone()上使用reflector,它似乎与配置文件或用户配置文件有关,如您在stacktrace中看到的

    关于它试图找到什么配置文件以及为什么找不到它们有什么想法吗?

    3 回复  |  直到 9 年前
        1
  •  2
  •   Richard    16 年前

    使用 Process Monitor (或增强您的日志记录)以标识未找到哪个文件。

        2
  •  0
  •   Daniel Dolz    16 年前

    我将使用sysinternal“filemon”。

    它是一个应用程序,捕捉每一个IO尝试,成功与否。使用pacience,您将看到未找到文件名。

        3
  •  0
  •   Buzz    9 年前

    我遇到过这个问题。在我的例子中,当我从构建服务器中提取发布应用程序并在开发机器上运行它时,我从findone发出的一系列调用中得到了filenotfoundexception。我在桌面上运行此版本,模拟帐户也没有完全访问权限。我把发布文件夹移到了C驱动器上,运行良好。 在我的例子中,这段代码是为允许多次登录尝试的登录对话框执行的。由于上述原因,它第一次失败了,但下一次成功了,这似乎很奇怪。我只能假设findone第二次最终会遵循不同的路径,但目前我还没有真正找到确切的问题所在。在我的情况下,访问问题是有道理的,所以我不会从那里逃跑。 也许这更多的是给别人一个线索,而不是一个解决方案。

    推荐文章