Click here to Skip to main content
15,890,186 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am having trouble passing a serialized object from one program to another.

The two programs are compiled in the same solution and are running on the same computer. The object source is in a shared folder in the same solution.
Program A serializes the object and writes it to a named pipe.
Program B reads the serialized object from the named pipe and attempts to assign the de-serialized object to the same object type.

I receive the following error:

[A]FileFind.FileFind.Shared.cs.CMUtilitySchedule cannot be cast to [B]FileFind.FileFind.Shared.cs.CMUtilitySchedule.
Type A originates from 'FileFind, Version=5.0.0.6, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'I:\RogerFolders\Documents\Visual Studio 2013\Projects\Test\FileFind\FileFind6000\FileFind\FileFind\bin\Debug\FileFind.exe'.
Type B originates from 'FileFindCM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'I:\RogerFolders\Documents\Visual Studio 2013\Projects\Test\FileFind\FileFind6000\FileFind\FileFind\bin\Debug\FileFindCM.exe'.

How can I pass objects to another running program via a pipe?

What I have tried:

I am thinking of creating a function in the object that will create a CVS or XML stream. I would then serialize the resulting stream and send it to the other program. However, that would be a non-intuitive maintenance nightmare.

Other suggestions would be welcome.
Posted
Updated 7-Oct-18 6:23am

1 solution

See this case:
C#
// project for A.exe
namspace A {
  public class FileFind {
    // ...
  }

  class A {
    public static void Main(string[] args) {
      // using FileFind...
    }
  }
}

// project for B.exe
namspace B {
  public class FileFind {
    // ...
  }

  class B {
    public static void Main(string[] args) {
      // using FileFind...
    }
  }
}

In this case there are two different types even FileFind has the exact same code in project A and B...
To resolve it you have to move FileFind to a third project and reference it both from A and B
C#
// project for F.dll
namspace F {
  public class FileFind {
    // ...
  }
}

// project for A.exe
using F;

namspace A {
  class A {
    public static void Main(string[] args) {
      // using F.FileFind...
    }
  }
}

// project for B.exe
using F;
namspace B {
  class B {
    public static void Main(string[] args) {
      // using F.FileFind...
    }
  }
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900