3

I have a POCO (plain old clr object) stored in session, and would like to be able to reference properties from that object from within another process (B). I don't want the stand-alone process (B) to require a reference to the dll in which the poco's class is defined. Is it possible to convert the saved object (in session) to something readable (e.g. xml) without referencing the object's class?

2
  • What is session here and how is it stored?
    – user76035
    Mar 17, 2009 at 16:40
  • An asp.net session, using State Server.
    – Jeremy
    Mar 17, 2009 at 16:47

4 Answers 4

1

You would have to create your own custom code to serialize and/or deserialize the object.

Without a reference to the assembly .NET does not have the needed meta data to do the work for you.

You can just add an attribute to the generated XML to specify the object type.

<Object Type="1">
    <Property1>Value</Property1>
</Object>

Of course the destination code would need to know what to do with this type attribute, but you would not need to reference the actual .NET assembly.

1

you cant you need the assembly to get the metadata of the object, maybe you can avoid the reference to the dll and use reflection.

0

If you just need a snapshot of the object, then yes, you can simply serialize it (or just the properties you're interested in) and then pass the serialized data to process B. The XmlSerializer class probably provides the simplest way to serialize the object and then process B can read the data using any standard XML parser.

3
  • How would you use the XmlSerializer without having a reference and knowing the type? Mar 17, 2009 at 16:37
  • @JDaniel: Agreed, once it's in Xml. Without knowing the type, how can you serialize it in the first place? Mar 17, 2009 at 16:53
  • I believe jmaddrey was trying to avoid referencing the DLL from process B. Presumably process A is already referencing the DLL. Mar 18, 2009 at 23:13
0

Forgetting about how to serialize it - how are you going to retrieve the data in another process. What is this other process? If it's not another ASP.NET page, then it will have no access to Session state!

2
  • Perhaps "process" was not the best choice of words. The dlls are executing in the same process (asp.net). The other dll (previously referred to as B) is shared by many apps. The session variable I want to deserialize is specific to one app. I am trying to avoid the shared dll having a "one-off".
    – Jeremy
    Mar 17, 2009 at 17:21
  • How will this data be used by Assembly B when it is running in Web App A? What will Assembly B do when it is running in a different application, and are the other applications all web apps? Mar 17, 2009 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.