【发布时间】:2012-10-15 22:04:16
【问题描述】:
让我先说我不认为这是一个重复的问题,但这可能是因为我没有完全理解这个问题。
听起来这个例外是设计使然,至少根据我读过的许多帖子。但是,这个异常会定期破坏我的应用程序。如果再次调用 Web 服务,它似乎可以工作(神奇!)。但是,我希望第一个 Web 服务调用能够正常工作。
这是正在记录的异常:
System.IO.FileNotFoundException: Could not load file or assembly 'Our.Namespace.Here.ClassName.XmlSerializers' or one of its dependencies. The system cannot find the file specified.
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.LoadWithPartialNameInternal(AssemblyName an, Evidence securityEvidence, StackCrawlMark& stackMark)
at System.DirectoryServices.AccountManagement.UnsafeNativeMethods.IADsPathname.Retrieve(Int32 lnFormatType)
at System.DirectoryServices.AccountManagement.ADStoreCtx.LoadDomainInfo()
at System.DirectoryServices.AccountManagement.ADStoreCtx.get_DnsForestName()
at System.DirectoryServices.AccountManagement.ADStoreCtx.GetGroupsMemberOf(Principal p)
at System.DirectoryServices.AccountManagement.Principal.GetGroupsHelper()
at Our.Different.Namespace.ClassName.FindAccount(FindAccountRequest request, String ip, FindAccountResponse& response)
在发布模式下构建时,我没有将此 XmlSerializers 文件作为构建输出的一部分。听起来我可能可以force the file to be generated,但是,如何在不强制生成文件的情况下停止异常?
【问题讨论】:
-
您是否尝试动态加载与正在执行的程序集不在同一文件夹中的程序集?
-
您的构建配置是否列出了在同一平台(x86、x64、任何平台等)上构建的所有程序集?
-
如果您引用的程序集之一是在 x86 上构建的,但调用程序集正在运行 x64(或 x64 机器上的 Any),则调用程序集将由于不兼容而无法加载引用的程序集。
-
@JoshC。 - 我不是动态加载程序集。 所有项目的平台设置为“Any CPU”。
-
您的项目是否引用了可能有点过时的程序集?有时它们被编译为 x86。如果是这种情况,您需要将正在执行的程序集编译为 x86。
标签: c# web-services exception xmlserializer