I think I found the real issue why I could not deserialize the file in the first place. If I place the assembly in the root folder of max it deserializes the file just fine. If I put the assembly in a folder and try to deserialize it throws the “Unable to find assembly…” error. Loading the assembly and using the “showmethods” method displays the static methods in the queried class, but when I try to use it it throws the error.
This works (with the assembly in the root folder):
(
dotNet.loadAssembly "ArtificialNeuralNetwork.dll"
ann = (dotNetClass "ArtificialNeuralNetwork.SerializationUtils").Deserialize ((getdir #scripts) + @"\MouseGesture\ann.bin")
)
This throws an error on the last line (with the assembly in root\scripts\MouseGesture\ folder):
(
dotNet.loadAssembly ((getdir #scripts) + @"\MouseGesture\MouseCapture.dll")
showmethods (dotnetclass "ArtificialNeuralNetwork.SerializationUtils") --displays the methods in this class
ann = (dotnetclass "ArtificialNeuralNetwork.SerializationUtils").deserialize ((getdir #scripts) + @"\MouseGesture\ann.bin") --throws the error
)
This is the deserialize method in the assembly, nothing special about it:
public static object Deserialize(string filename)
{
Stream stream = File.OpenRead(filename);
BinaryFormatter deserializer = new BinaryFormatter();
object obj = deserializer.Deserialize(stream);
stream.Close();
return obj;
}
I’m using other methods from the same assembly and they are working just fine.
What am I doing wrong?