私はこれを試しました、そしてそれは私のために働きました。
AxShockwaveFlashObjects.AxShockwaveFlashからクラスを派生させ、ISerializableインターフェイスを実装しました。
GetObjectDataとシリアル化コンストラクターを実装しました。それらのコーディングはあまりありません。
[Serializable()]
class MyCustomFlash : AxShockwaveFlashObjects.AxShockwaveFlash, ISerializable
{
public MyCustomFlash()
{
}
public MyCustomFlash(SerializationInfo info, StreamingContext ctxt)
{
//dont think this is required.
this.OcxState = (State)info.GetValue("ocxstate", typeof(State));
}
#region ISerializable Members
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
//dont think this is required.
// info.AddValue("movie", this.Movie);
info.AddValue("ocxstate", this.OcxState);
}
#endregion
}
私はwinformを使用していました。したがって、を使用してムービーを埋め込むようにしてください
axShockwaveFlash1.EmbedMovie = true;
//loadMovie follows
次に、通常のバイナリシリアル化/脱セリル化を試してください。
逆シリアル化中に、シリアル化されたフラッシュを別のフォームに追加しようとしました。
ただし、AxHost + InvalidActiveXStateExceptionが発生し続けると、コントロールがフォームに表示されませんでした。コントロールはフォームで開始されていなかったと思います。
デザイナーの初期化コードをコピーするだけで、機能します。
string serialFilePath = @"E:\test\serialFiles\DataFile.dat";
FileStream myFS = new FileStream(serialFilePath, FileMode.Open);
// Create a binary formatter object to deserialize the data
BinaryFormatter myBF = new BinaryFormatter();
MyCustomFlash flashObj;
//where class MyCustomFlash : AxShockwaveFlashObjects.AxShockwaveFlash, ISerializable
flashObj = (MyCustomFlash)myBF.Deserialize(myFS);
//this is code from VS designer..need to initialise flash control
((System.ComponentModel.ISupportInitialize)(flashObj)).BeginInit();
myFS.Close();
flashObj.Enabled = true;
this.Controls.Add(flashObj);
((System.ComponentModel.ISupportInitialize)(flashObj)).EndInit();
flashObj.Name = "Axflash";
flashObj.Visible = true;
flashObj.Location = new System.Drawing.Point(12, 12);
flashObj.Size = new System.Drawing.Size(309, 207);
お役に立てれば :)
thx
amitd