My scenario - I am trying to send a Assembly File from Server to Client (via direct TCP connection). But the major problem is- how do I convert this Assembly to bytes to that it can be readily transferred? I used following -
byte[] dllAsArray;
using (MemoryStream stream = new MemoryStream())
{
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(stream,loCompiled.CompiledAssembly);
dllAsArray = stream.ToArray();
}
But when I use -
Assembly assembly = Assembly.Load(dllAsArray);
I get an exception -
Could not load file or assembly '165 bytes loaded from Code generator server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format. Please help!!!