I am trying to create a new appdomain and load an assembly into it using
the AppDomain.Load() method. When I try the following code
 
 
AppDomainSetup domainSetup = new AppDomainSetup();
domainSetup.ApplicationBase = @"<path to file>";
domainSetup.ApplicationName = "Component";
                                    
Evidence remoteEvidence = AppDomain.CurrentDomain.Evidence; AppDomain
remoteDomain = AppDomain.CreateDomain("remoteDomain",
remoteEvidence, domainSetup);
 
try
{
            remoteDomain.Load(@"NeutralAssembly");
}
catch(Exception e)
{
            Console.WriteLine(e.ToString());
 
}
 
I get an error saying
 
System.Runtime.Serialization.SerializationException: Insufficient state
to deser ialize the object.  More information is needed.
 
Server stack trace:
   at System.UnitySerializationHolder.GetRealObject(StreamingContext
context)
   at
System.Runtime.Serialization.ObjectManager.ResolveObjectReference(Object
Ho
lder holder)
   at System.Runtime.Serialization.ObjectManager.DoFixups()
   at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(
He
aderHandler handler, __BinaryParser serParser, Boolean fCheck,
IMethodCallMessag e methodCallMessage)
   at
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deseriali
ze
(Stream serializationStream, HeaderHandler handler, Boolean fCheck,
IMethodCallM essage methodCallMessage)
   at
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deseriali
ze
(Stream serializationStream, HeaderHandler handler, Boolean fCheck)
   at
System.Runtime.Remoting.Channels.CrossAppDomainSerializer.DeserializeObj
ec
t(MemoryStream stm)
   at
System.Runtime.Remoting.Channels.CrossAppDomainSerializer.DeserializeMes
sa
geParts(MemoryStream stm)
   at
System.Runtime.Remoting.Messaging.SmuggledMethodReturnMessage.FixupForNe
wA
ppDomain()
   at
System.Runtime.Remoting.Channels.CrossAppDomainSink.SyncProcessMessage(I
Me
ssage reqMsg)
 
Exception rethrown at [0]:
   at
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
req
Msg, IMessage retMsg)
   at
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgDa
ta, Int32 type)
   at System.AppDomain.Load(String assemblyString)
   at HostApplication.Entrypoint.Main(String[] args) 
 
The NeutralAssembly is just a Class Library with one class in it that
has no actuall code
 
Public class class1
{
   public class1()
   {
    }
}
 
I’ve also tried with a different assembly with a couple of classes in
them with a bit more code and it gives me the same error.
 
Any ideas? =)
 
// Andreas Håkansson
 
 

Reply via email to