1

在尝试在 C# 和 flash 对象 (swf) 之间进行通信时,我遇到了以下异常。我尝试使用 Flash64_13_0_0_214.ocx 生成 2 个程序集 AxShockwaveFlash.dll 和 ShockwaveFlashObject.dll,然后我在一个控制台应用程序中测试我的代码。我的代码一般是这样的:

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

点击 LoadMovie 后,我收到以下错误:

System.AccessViolationException 未处理 HResult=-2147467261 消息=尝试读取或写入受保护的内存。这通常表明其他内存已损坏。
Source=ShockwaveFlashObjects StackTrace:在 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 () 在 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()

请帮帮我~~

4

1 回答 1

0

嗨,我遇到了同样的问题,我发现只有在加载表单之前调用 LoadMovie 才会发生此错误。修复是在表单加载时添加事件,并将代码在那里创建冲击波闪光。

在你的情况下:

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");
    }
}
于 2015-02-25T10:24:17.730 回答