Instead of identifying the context of the assembly, you could test the behavior of it. For example, for serializing, the serializer will call Assembly.Load and that assembly must match the assembly of the object being serialized. A match can be tested for by checking the CodeBase.
private static bool DoesAssemblyMatchLoad(Assembly assemblyToTest)
{
try
{
var loadedAssembly = Assembly.Load(assemblyToTest.FullName);
return assemblyToTest.CodeBase == loadedAssembly.CodeBase;
}
catch (FileNotFoundException)
{
return false;
}
}