I have a program, that show messagebox.
Another app opens it, read and writes to string in text file

Code:
byte[] plain = File.ReadAllBytes(file);
byte[] encode = encodeBytes(plain, pass);   //simple xor
...
int index = something.IndexOf("arr=\"");
string ready = Convert.ToBase64String(encodedBytes);
string modified = something.Insert(index+5, ready);
File.WriteAllBytes(txtFile, Encoding.ASCII.GetBytes(modified));
In another app I'm trying to execute code:

Code:
string arr="base64_code";
byte[] newBytes = Convert.FromBase64String(arr);
byte[] buffer =null;buffer = decryptBytes(newBytes,pass); //XOR
if(System.Text.Encoding.UTF8.GetString(buffer).Contains("</assembly>"))
{
     Assembly exeAssembly = Assembly.Load(buffer);
     object[] parameters =newobject[1];     
                          exeAssembly.EntryPoint.Invoke(null, parameters);
}

Debugger shows error "System.BadImageFormatException", but if I run saved code from file (app reads code from txt), it executes without problems. How i can run code from string?
Thanks and sorry for my english