?
Solved

desrialization throwing a "Parse Error exception"

Posted on 2004-04-25
2
Medium Priority
?
1,129 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
heboh earned 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

777 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