1

Let me preface this by saying I don't think this is a duplicate question, but, that may be because I am not fully understanding this issue.

It sounds like this exception is by design, at least according to the many posts I've read. But, this exception is periodically breaking my application. If the web service call is made again, it seems to work (magic!). But, I want that first web service call to work.

This is the exception that is being logged:

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)

I do not get this XmlSerializers file as part of my build output when building in release mode. It sounds like I might be able to force the file to be generated, but, how can I get the exception to stop without forcing the file to be generated?

Community
  • 1
  • 1
Justin Helgerson
  • 24,900
  • 17
  • 97
  • 124
  • Are you trying to dynamically load assemblies that are not in the same folder as the executing assembly? – Josh C. Oct 25 '12 at 16:54
  • Does your build config list all assemblies being built on the same platform (x86, x64, Any Platform, etc.)? – Josh C. Oct 25 '12 at 16:55
  • If one of your referenced assemblies is built on x86, but the calling assembly is running x64 (or Any on an x64 machine), the calling assembly will fail to load the referenced assembly because of the incompatibility. – Josh C. Oct 25 '12 at 16:56
  • @JoshC. - I'm not dynamically loading assemblies. The platform for *all* projects is set to "Any CPU". – Justin Helgerson Oct 25 '12 at 16:59
  • Do any of your projects reference an assembly that may be a bit dated? Sometimes those are compiled as x86. If that were the case, you would need your executing assembly to be compiled as x86. – Josh C. Oct 25 '12 at 17:37
  • The main web service project and the project that is trying to have its XmlSerializers file loaded both don't look to have any dated references (though, I'm not sure what constitutes a dated reference). – Justin Helgerson Oct 25 '12 at 18:13
  • I've particularly had problems with assemblies that were compiled before the popularity of x64 processors in home computers (early 2000s and before). – Josh C. Oct 25 '12 at 19:01

2 Answers2

0

The problem root in this case is a networking issues communicating with Active Directory. The FileNotFoundException occurred then during attempt to serialize COM exception (in IADsPathname COM-interface). This FileNotFoundException is a part of the XmlSerializer's normal operation. It is expected and will be caught and handled inside of the Framework code (it will cause required assembly generation). Just ignore it and continue.

Vlad Rudenko
  • 2,363
  • 1
  • 24
  • 24
0

I've got similar error messages, and the root cause turns out to be this AD bug (https://support.microsoft.com/en-us/kb/2683913) in versions of Windows, whilst using the System.DirectoryServices.AccountManagement namespace in .NET.

Dave Glassborow
  • 3,253
  • 1
  • 30
  • 25