Hello Scott,
At first, I agreed with you, but after further examination I am feeling very certain that it is a problem with TypeMock. However, it is not easily reproduced - I am only experiencing it with certain assemblies and I have yet to find what causes it. I am thinking that you guys (knowing what typemock does) might be able to deduce it. Here goes:
The problem has to do with typeloading, and what looks to be shadowcopy - or some mechanism like it.
Problem: When TypeMock.Init has been called, creating a XmlSerializer of types in *certain* assemblies does not work. If TypeMock is not loaded (no init called), everything works fine. I am using an exe to test (in order to isolate):
using System;
using System.Xml.Serialization;
using TypeMock;
using XXXX.Core.Cache.Configuration; // I put "Apa2.MyTestClass" in this ambly
public class Class1
{
public static void Main()
{
MockManager.Init();
XmlSerializer serializer2 = new XmlSerializer( typeof(Apa2.MyTestClass) );
MockManager.Verify();
}
}
This throws the aforementioned FileNotFound exception (see previous message). Commenting MockManager.Init will make the code run through with no hitch. (In order to isolate, the class "MyTestClass" is a dummy with no content whatsoever. The important thing is the assembly it resides in.
)
Looking at whats going on with the binding, a temp dll is created and it seems to try to use it for the MyTestClass type, yet I have not confirmed this. Using filemon I see that the DLL is deleted and subsequently an attempt to open it fails. Fusion gives this pruned looking log:
*** Assembly Binder Log Entry (7/11/2006 @ 2:20:39 PM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:WINDOWSMicrosoft.NETFramework1.1.4322usion.dll
Running under executable C: emp estsTMProblempaexeinDebugpaexe.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: Where-ref bind. Location = C:DOCUME~1CUSWLOCALS~1Tempppoqjrwk.dll
LOG: Appbase = C: emp estsTMProblempaexeinDebug
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : (Unknown).
===
LOG: Processing DEVPATH.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/DOCUME~1/CUSW/LOCALS~1/Temp/ppoqjrwk.dll.
LOG: All probing URLs attempted and failed.
As I said though, here is the rub: This only happens for certain assemblies. I have no idea what makes them special (so far only working with one).
If I reference another type in another assembly, no temp dll is created at all. If I comment out MockManager.Init, no temp dll is created. So typemock seems to either be creating it or be indirectly responsible for that it gets created.
I really hope you guys have an idea of what this is about!
Best regards,
Marcus Widerberg
PS
The assembly has a strong name (not in GAC though). Dunno if that matters.