Error loading Assembly at runtime into new application domain

G

Guest

Hi,

I’ve been having an intermittent problem with an exception being thrown and
cannot work out why. The program works 99% of the time but a couple of times
a day a Serialization Exception will occur stating that it cannot find an
assembly. Not only is the assembly there but it will then load it a couple of
minutes later with no problems.

The program loads Assemblies at runtime into a new application domain which
works fine each time, it is a dependency of that assembly which cannot be
found.

The exception that I get is the following

System.Runtime.Serialization.SerializationException: Cannot find the
assembly PlatformMainframe, Version=1.0.2119.17997, Culture=neutral,
PublicKeyToken=null.

Server stack trace:
at
System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly()
at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name)
at System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String
objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[]
typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32
objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)
at System.Runtime.Serialization.Formatters.Binary.ObjectMap.Create(String
name, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[]
typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32
objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)
at
System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)
at
System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler
handler, __BinaryParser serParser, Boolean fCheck, IMethodCallMessage
methodCallMessage)
at
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream
serializationStream, HeaderHandler handler, Boolean fCheck,
IMethodCallMessage methodCallMessage)
at
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck)
at
System.Runtime.Remoting.Channels.CrossAppDomainSerializer.DeserializeObject(MemoryStream stm)
at
System.Runtime.Remoting.Channels.CrossAppDomainSerializer.DeserializeMessageParts(MemoryStream stm)
at
System.Runtime.Remoting.Messaging.SmuggledMethodReturnMessage.FixupForNewAppDomain()
at
System.Runtime.Remoting.Channels.CrossAppDomainSink.SyncProcessMessage(IMessage reqMsg)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type)
at Platform.Host.RobotBase.Start()
at Platform.Host.ExecutionPlan.ThreadProc() in d:\visual studio
projects\platform\platform\host\executionplan.cs:line 236

The line 236 mentioned above is the entry point into the loaded assembly in
the new Application Domain.

The code used to create new application domain and load the assembly is as
follows (I substituted variables for string values for ease of reading)

applicationDomain =
AppDomain.CreateDomain(“newappDomainâ€,AppDomain.CurrentDomain.Evidence,â€c:\\assemblies\\â€,"\\",true);

object obj =
applicationDomain.CreateInstanceFromAndUnwrap(â€c:\\assemblies\\assembly.dllâ€,
“assemblytypeâ€);

If you require any more details or source code please tell me and I will
post it.
 
G

Guest

Hi,

The tool below shows when the assemblies are loaded but it doesnt display
any information about the assemblies that are added as a reference to the
loaded assemblies.
 
P

Peter Huang [MSFT]

Hi

You may try to select the item in the fuslogvw tool and click View Log
button to view the detailed binding information.
Also for such seldom reproduced problem I recommended you contact MSPSS
directly because it may need dump analysis.
http://support.microsoft.com

Thanks for your understanding!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top