I am working on two DLLs, being called by an application. Everything is programmed in C#.
Recently I've tried to work with pre-build events, in order to add some versioning information to the DLLs. I have removed all that work: in GIT, all files (project files, source files, AssemblyInfo.cs) are present in GIT and there are all changes are deleted. There are just some leftovers (like FixedAssemblyInfo.cs
files and AssemblyInfo_Orig.cs
), but those are not referred to in the project files.
In order to work with the DLLs, I build them into a Modules
directory and I use Application_Server.exe
as an external program for running the DLL. That application is the same for both DLLs.
When I try to work with DLL1, everything is working fine.
When I try to work with DLL2, I have the following weird error message:
Source code (source_file.cs
):
using System.Xml;
using System.Xml.Serialization;
...
var serializer = new XmlSerializer(base.GetType());
Error message (Exception
thrown):
System.IO.FileNotFoundException:
'Could not load file or assembly 'Application_Server.XmlSerializers,
Version=1.0.0.0, ...' or one of its dependencies.
The system cannot find the file specified.'
Why is this strange?
source_file.cs
belongs toDLL1
, not toDLL2
(and I'm busy working withDLL2
).- When I launch
DLL1
(which launches the same external application asDLL2
), everything is working fine.
Anybody has an idea why DLL2
does not want to refer to System.xml.dll
, and this in a source file of DLL1
while that same DLL1
does not have that problem?
Thanks in advance
Edit: Process Explorer results:
I just ran Process Explorer (while debugging DLL2
in Visual Studio, having the Exception
's error message open): apparently Application_Server.exe
has System.XML.dll
loaded.
Edit: callstack:
Hereby the (partial) callstack when the Exception
occurs:
mscorlib.dll!System.Reflection.RuntimeAssembly.nLoad(System.Reflection.AssemblyName fileName, string codeBase, System.Security.Policy.Evidence assemblySecurity, System.Reflection.RuntimeAssembly locationHint, ref System.Threading.StackCrawlMark stackMark, System.IntPtr pPrivHostBinder, bool throwOnFileNotFound, bool forIntrospection, bool suppressSecurityChecks) Line 1951 C#
mscorlib.dll!System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(System.Reflection.AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity, System.Reflection.RuntimeAssembly reqAssembly, ref System.Threading.StackCrawlMark stackMark, System.IntPtr pPrivHostBinder, bool throwOnFileNotFound, bool forIntrospection, bool suppressSecurityChecks) Line 1859 C#
mscorlib.dll!System.Reflection.Assembly.Load(System.Reflection.AssemblyName assemblyRef) Line 363 C#
System.Xml.dll!System.Xml.Serialization.TempAssembly.LoadGeneratedAssembly(System.Type type, string defaultNamespace, out System.Xml.Serialization.XmlSerializerImplementation contract) Unknown
System.Xml.dll!System.Xml.Serialization.XmlSerializer.XmlSerializer(System.Type type, string defaultNamespace) Unknown
System.Xml.dll!System.Xml.Serialization.XmlSerializer.XmlSerializer(System.Type type) Unknown
>Application_Server.dll!Application_Server.Communication.Messagess.Message.ToString() Line 123 C#
Edit: Project properties "Build" tabpage
My Project's "Build" properties page looks as follows (both for DLL1
and DLL2
):
(As that modification does not solve the issue, I've decided to remove it.)
Important edit: modification of bad reference
In DLL1
, there was a reference to an older version of DLL2
. I have replaced that reference with a reference to the current DLL2
but that did not solve the issue (I've been checking the entries in the .FileListAbsolute.txt
in order to be sure).