Hi,
I am trying to find the correct structure of my “Spider” project in Visual Studio. Currently I have my SpiderBase-class, and SpiderBaseGoo-class in a separate SpiderGH.dll. My Components, and Parameters are placed in SpiderComponents.gha. In the future I want to create several Components-projects (.gha) and use the goo-baseclass from SpiderGH.dll.
The issue with this structure is that the Read-method on my base-goo is not called when it is placed in a .dll instead of .gha. I suspect that grasshopper only looks in assemblies ending width .gha for deserialization? When I place my goo-baseclass in the .gha-assembly serialization works perfectly. However, this structure prevents me from using the goo-baseclass as an reference in other component-assemblies.
I there an option where I can make grasshopper look in my SpiderGh.dll-assembly on deserialization/read, and would this fix my problem?
public abstract class GH_SpiderBaseGoo<T> : GH_GeometricGoo<T>, IGH_PreviewData, IGH_BakeAwareData, GH_ISerializable where T : SpiderBase
.
.
.
public override bool Write(GH_IWriter writer)
{
MemoryStream stream = new MemoryStream();
IFormatter formatter = new BinaryFormatter();
formatter.Serialize(stream, Value);
writer.SetByteArray("SpiderBase", stream.ToArray());
stream.Close();
return base.Write(writer);
}
public override bool Read(GH_IReader reader)
{
byte[] bytes = reader.GetByteArray("SpiderBase");
MemoryStream stream = new MemoryStream(bytes);
IFormatter formatter = new BinaryFormatter();
Value = (T)formatter.Deserialize(stream);
stream.Close();
return base.Read(reader);
}
Best,
Odd Eiken