运行库遇到了错误。此错误的地址为 0x79e85bb3,在线程 0x550 上。错误代码为 0xc0000005。此错误可能是 CLR 中的 bug,或者是用户代码的不安全部分或不可验证部分中的 bug。此 bug 的常见来源包括用户对 COM-interop 或 PInvoke 的封送处理错误,这些错误可能会损坏堆栈。

解决方案 »

  1.   

      private void button1_Click(object sender, EventArgs e)
            {
                string name = "";
                IWMMetadataEditor editor = null;
                IWMHeaderInfo3 headInfo = null;
                try
                {                if (DialogResult.OK == openFileDialog1.ShowDialog())
                    {
                        name = openFileDialog1.FileName;
                        uint hr = WMFSDKFunctions.WMCreateEditor(out editor);
                        uint hhr = editor.Open(name);
                        headInfo = editor as IWMHeaderInfo3;
                        ushort cntMarkers = 0;
                        headInfo.GetMarkerCount(out cntMarkers);
                        headInfo.GetScriptCount(out cntMarkers);
                        //headInfo.AddMarker("course.Name", 10000000);
                        //headInfo.AddScript("URL", "course.Name", 10000000);
                        for (ushort i = 0; i < cntMarkers; i++)
                        {
                            string n = "";
                            ushort reqlen = 0;
                            ulong time=0;
                            string type = "";
                            string command = "";
                            ushort comLen = 0;
                            uint h = headInfo.GetMarker(i, null, ref reqlen, out time);
                            h = headInfo.GetMarker(i, n, ref reqlen, out time);
                            listView1.Items.Add(n);
                            //这里运行一次之后就会出现上述错误                        //*
                            headInfo.GetScript(i, null, ref reqlen, null, ref comLen, out time);
                            headInfo.GetScript(i, type, ref reqlen, command, ref comLen, out time);
                            MessageBox.Show(type);
                            MessageBox.Show(command);
                          //*/
                        }
                    }
                }
                catch (Exception ex)
                {                MessageBox.Show(ex.Message);
                }
                finally
                {
                    //if (editor != null)
                    {
                        //editor.Flush();
                        //editor.Close();
                    }
                }
            }
      

  2.   

    你的问题主要就是平台调用过程中的数据封送问题。楼上有人已经给出了正确的答案。但是如果只获得答案,不知道原理,以后遇到了此类问题还是不知道如何下手。如果你想系统学习如何进行数据封送,我推荐你阅读刚刚出版的新书:《精通.NET互操作P/Invoke,C++Interop和COM Interop》,这本书的第2章“数据封送”详细介绍了平台调用中的数据封送过程,非常详细,我就是读完后才搞清楚平台调用中的封送处理。 
    该书的官方网站: 
    www.interop123.com 豆瓣网信息: 
    http://www.douban.com/subject/3671497/