Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 错误:类型为';系统。无效卡斯特例外';在WebKitBrowser.dll中发生_C#_.net_Multithreading_Webkit_Webkit.net - Fatal编程技术网

C# 错误:类型为';系统。无效卡斯特例外';在WebKitBrowser.dll中发生

C# 错误:类型为';系统。无效卡斯特例外';在WebKitBrowser.dll中发生,c#,.net,multithreading,webkit,webkit.net,C#,.net,Multithreading,Webkit,Webkit.net,我尝试在等待几秒钟后按顺序打开应用程序中的多个URL。但我在运行我的项目时遇到了以下异常。我把我的代码也放在这里,请让我知道我做错了什么,实现这个要求的最佳方式是什么。如果您需要有关我的项目配置的任何其他信息,请告诉我 例外情况: WebKitBrowser.dll中首次出现“System.NotImplementedException”类型的异常 System.dll中出现“System.UriFormatException”类型的首次意外异常 WebKitBrowser.dll中发生了类型为

我尝试在等待几秒钟后按顺序打开应用程序中的多个URL。但我在运行我的项目时遇到了以下异常。我把我的代码也放在这里,请让我知道我做错了什么,实现这个要求的最佳方式是什么。如果您需要有关我的项目配置的任何其他信息,请告诉我

例外情况: WebKitBrowser.dll中首次出现“System.NotImplementedException”类型的异常
System.dll中出现“System.UriFormatException”类型的首次意外异常
WebKitBrowser.dll中发生了类型为“System.InvalidCastException”的首次意外异常
WebKitBrowser.dll中发生了类型为“System.InvalidCastException”的首次意外异常
WebKitBrowser.dll中发生了类型为“System.InvalidCastException”的首次意外异常
线程0x3b8c已退出,代码为259(0x103)。
线程0xf04已退出,代码为259(0x103)。
程序“[0x2F30]WebKitProject.vshost.exe:程序跟踪”已退出,代码为0(0x0)。
程序“[0x2F30]WebKitProject.vshost.exe”已退出,代码为0(0x0)

节目:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading;
    using System.Windows.Forms;
    using WebKit.Interop;

    namespace WebKitProject
    {
        public partial class Form1 : Form
        {                
            private string[] urls = new string[] { "http://www.google.com", "http://www.whatsmyip.org", "http://www.bling.com", "http://www.facebook.com" };
            int urlPointer = 0;


            public Form1()
            {
                InitializeComponent();            
            }

            private void Form1_Load(object sender, EventArgs e)
            {
               openBrowser(sender, e);           
            }

            private void openBrowser(object sender, EventArgs e)
            {
                if (urlPointer < urls.Length)
                {
                    String urlStr = urls[urlPointer];
                    urlPointer++;

                    this.webKitBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webKitBrowser1_Completed);
                    webKitBrowser1.Navigate(urlStr);
                }       
            }

            void webKitBrowser1_Completed(object sender, WebBrowserDocumentCompletedEventArgs e)
            {
                System.Timers.Timer timer = new System.Timers.Timer(5000);
                timer.Elapsed += new System.Timers.ElapsedEventHandler(openBrowser);
                timer.Start();
            }
        }
    }
使用系统;
使用System.Collections.Generic;
使用系统组件模型;
使用系统数据;
使用系统图;
使用System.Linq;
使用系统文本;
使用系统线程;
使用System.Windows.Forms;
使用WebKit.Interop;
命名空间WebKit项目
{
公共部分类Form1:Form
{                
私有字符串[]URL=新字符串[]{”http://www.google.com", "http://www.whatsmyip.org", "http://www.bling.com", "http://www.facebook.com" };
int urlPointer=0;
公共表格1()
{
初始化组件();
}
私有void Form1\u加载(对象发送方、事件参数e)
{
openBrowser(sender,e);
}
私有void openBrowser(对象发送者、事件参数)
{
if(urlPointer
您尝试调试它的是什么?这种情况是否也只发生在一个URL上?每个URL或只是特定的URL?当我从webKitBrowser1_Completed方法调用openBroswer方法而不是使用计时器时,它会在加载前一个URL后立即打开URL,但当我使用计时器调用时,会出现我提到的异常。我认为,这是因为它创建了一个新线程,而将webkitBrowser1对象与新线程一起使用就是在创建这个异常。