Problems with serializaton/deserialization

roger_74 wrote on 4/14/2003, 5:38 PM
Are there any known issues with serializaton/deserialization in VSA/Vegas? I'm serializing an object in my own assembly and it works fine. But deserializing it back does not work. Vegas (or VSA I guess) says that it can't find my assembly. I get a System.Runtime.Serialization.SerializationException: Cannot find the assembly.

If I put everything including the script and assembly dll in my Vegas 4.0 directory, I get a little further, but instead I get an invalid cast exception when I cast the output from the binary formatter to my local variable. The thing is, everything works great if I don't run it from inside Vegas. So there shouldn't be anything wrong with it.

Comments

roger_74 wrote on 4/14/2003, 6:11 PM
Ok, I figured out the part about the cast exception. When I moved the assembly to the Vegas program folder it is no longer considered the same assembly.

But the first problem remains, why can't I deserialize an object in my own assembly unless the script is run from the Vegas program directory?
SonyPJM wrote on 4/15/2003, 9:16 AM

I'm not familiar with the details of serialization so I'm afraid I
can't help very much but I will keep my eye out.

This sounds similar to the problem with using local assemblies from a
VB script... the VSA engine seems to limit its search path to the GAC
and the directory containing the ScrpitHost assembly.

If this continues to be an issue it might be helpful, in future
releases, for us to install the ScriptHost assembly in a subdirectory
of the Vegas install directory so that users and developers such as
yourself can add assemblies to a known/isolated location.
roger_74 wrote on 4/15/2003, 12:01 PM
I don't know how VSA works and how much one can customize it, but in this article the author talks about loading assemblies at run-time (which I would assume VSA does). If the assembly is loaded with System.Reflection.Assembly's LoadFrom method, then it only looks in the GAC and the application's directory. There is another method one can use though, System.Reflection.Assembly.LoadWithPartialName. Perhaps VSA can be customized to use the other method?
SonyPJM wrote on 4/15/2003, 1:44 PM
With VSA, you just add assembly reference items to the script engine. These items are just assembly names and (optionally) paths. The script engine does the loading. I'm not sure exactly which method it uses and, from what I can tell, VB and JScript do it differently.

Maybe you can load the assembly "manually" in your script but you may need to combine this with an assembly reference for the script engine which can be added using the script's config XML file.