none
Issues with MEF + deserilization RRS feed

  • Question

  • Hi,

    I've developed a plugin for my MEF-based application (c# 4.0), and it uses it's own serialize / deserialize utility for persisting state data (BinaryFormatter). On it's own outside of MEF, the plugin project works fine and can store it's state to a file and retrieve it on next session. However, when working with the MEF host, the plugin's deserialization fails. While the plugin is able to serialize objects, when it tries to deserialize them (e.g., on the next line of code) it throws "unable to find assembly..." and the assembly it can't find is it's self (!!!!).

    By the way, the test object that was serialized is a dummy defined within the plugin project. No issues here. And, MEF solution, apart from this issue, seems to be working fine - Assemblies found, export/imports resolved.

    I'm new to MEF and so unsure what the problem is. Any thoughts appreciated.

    Thanks!

    Friday, March 15, 2013 1:54 PM

Answers

  • This problem is now solved. Mike, Christian - thanks for your input.

    To get things working, I located all assemblies (host + plugins) in a single location on the file system. Idealy I wanted to locate the plugins under host\bin\Debug\plugin but when I located them under host\bin\Debug the problem went away. (When creating my MEF catalog I simply filtered the dll's by name "*Plugin.dll". Not as tidy as a separate directory, and requires naming convention for plugins...but it works). 

    I'm not sure why the problem. Still a bit hazy on this subject area - any thoughts, in light of this workaround, are welcome.

    -Tom

    • Marked as answer by tom.j.walker Sunday, March 31, 2013 2:20 PM
    Sunday, March 31, 2013 2:19 PM

All replies

  • Hi Tom,

    Welcome to the MSDN Forum.

    I am trying to involve some other one into this case, please wait it patiently.

    Thank you.


    Mike Feng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, March 18, 2013 12:53 PM
    Moderator
  • Hi,

    Try check with these articles:

    - http://spazzarama.com/2009/06/25/binary-deserialize-unable-to-find-assembly/

    - http://stackoverflow.com/questions/868682/deserialization-error-in-mef-due-to-missing-assemblies


    Regards,
    Christian HL
    Microsoft Online Community Support


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Tuesday, March 19, 2013 7:22 AM
  • This problem is now solved. Mike, Christian - thanks for your input.

    To get things working, I located all assemblies (host + plugins) in a single location on the file system. Idealy I wanted to locate the plugins under host\bin\Debug\plugin but when I located them under host\bin\Debug the problem went away. (When creating my MEF catalog I simply filtered the dll's by name "*Plugin.dll". Not as tidy as a separate directory, and requires naming convention for plugins...but it works). 

    I'm not sure why the problem. Still a bit hazy on this subject area - any thoughts, in light of this workaround, are welcome.

    -Tom

    • Marked as answer by tom.j.walker Sunday, March 31, 2013 2:20 PM
    Sunday, March 31, 2013 2:19 PM
  • You probably want to add your "plugin" directory to the assembly binding section in your hosts app.config:

    <configuration>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <probing privatePath="plugin"/>
        </assemblyBinding>
      </runtime>
    </configuration>

    Tuesday, April 2, 2013 1:58 AM
  • Tried this but no joy.
    Saturday, April 6, 2013 9:46 AM