Solved

desrialization throwing a "Parse Error exception"

Posted on 2004-04-25
2
1,063 Views
Last Modified: 2007-12-19
I am trying to deserialize using the SoapFormatter.

The object I am trying to deserialzed is not directly referenced by the current assembly and class.
However, i added the particular assembly to the current AppDomain using the AppDomain.CurrentDomain.Load(rawAssembly, rawSymbolStore);

I thought this would work. but instead it throws an exception with the message:
Message      "Parse Error, no assembly associated with Xml key a3:http://schemas.microsoft.com/clr/nsassem/TestAgent/AgentPlay%2C%20Version%3D1.0.1577.29029%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull AgentPlay"      string


The required assembly is already loaded to the currently utilized AppDomain, how can I get the SoapFormatter to refer to the Assembly, when performing the desrialization process.

thanks kindly in advanced.


0
Comment
Question by:astaga
2 Comments
 
LVL 23

Expert Comment

by:rama_krishna580
ID: 10916351
0
 
LVL 1

Accepted Solution

by:
heboh earned 500 total points
ID: 10923366
the easiest thing to do is to implement the AppDomain.CurrentDomain.AssemblyResolve event before performing the desrialization operation. Have a look at the following code :

// Deserialization method
ResolveEventHandler lca = new ResolveEventHandler(LoadComponentAssembly);

AppDomain.CurrentDomain.AssemblyResolve += lca;
            
object anObject = sf.Deserialize(sw.BaseStream);

AppDomain.CurrentDomain.AssemblyResolve -= lca;

// Method for event

private static Assembly LoadComponentAssembly(object sender, ResolveEventArgs args)
{
   string simpleName = args.Name.Substring(0, args.Name.IndexOf(','));
  string assemblyPath = Path.Combine("..\\Agent\\",  simpleName + ".dll");
  return Assembly.LoadFrom(assemblyPath);
}
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question