1
votes

I am facing the following exception while trying to do communication between C# and flash object (swf). I try to aximp the Flash64_13_0_0_214.ocx to generate 2 assemblies AxShockwaveFlash.dll and ShockwaveFlashObject.dll, then i test my code in one Console Application. My code is generally like this:

AxShockwaveFlash player = new AxShockwaveFlash();
player.CreateControl();
player.WMode = "transparent";
player.AllowScriptAccess = "sameDomain";
player.Loop = false;
player.LoadMovie(0, @"encrypt.swf");

After hit LoadMovie, i got the following error:

System.AccessViolationException was unhandled HResult=-2147467261 Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=ShockwaveFlashObjects StackTrace: at ShockwaveFlashObjects.IShockwaveFlash.LoadMovie(Int32 layer, String url) at AxShockwaveFlashObjects.AxShockwaveFlash.LoadMovie(Int32 layer, String url) in c:\Windows\System32\AxShockwaveFlashObjects.cs:line 685 at TestActionScript2.Program.Main(String[] args) in c:\Something\trunk\Src\TestActionScript2\Program.cs:line 41 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()

Please help me~~

1

1 Answers

0
votes

Hy, i got same problems and i found out that this error occures only if you call LoadMovie beffore the form is loaded. Fix was to add event on Form load and put the code to create shockwaveflash there.

In your case:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();

        this.Load += new System.EventHandler(this.Form_Load);
    }

    private void Form_Load(object sender, EventArgs e)
    {
        AxShockwaveFlash player = new AxShockwaveFlash();
        player.CreateControl();
        player.WMode = "transparent";
        player.AllowScriptAccess = "sameDomain";
        player.Loop = false;
        player.LoadMovie(0, @"encrypt.swf");
    }
}