0
当我正在写一个Outlook加载项时尝试获取WebBrowser的.Url属性时,出现“Access Violation”运行时错误。需要一些帮助,如何通过这个请。研究表明我可能需要设置“FullTrust”权限集,尝试过没有成功。获取WebBrowser时遇到访问冲突运行时错误.Url属性
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Security;
using System.Security.Permissions;
namespace MyAddin1
{
public partial class authForm : Form
{
public string currentUrl;
public authForm()
{
InitializeComponent();
}
private void formLoaded(object sender, EventArgs e)
{
WebBrowser browser = new WebBrowser();
browser.Location = new System.Drawing.Point(0, 0);
browser.Width = 870;
browser.Height = 510;
browser.Navigate("https://www.yammer.com/dialog/oauth?client_id=<redacted>&response_type=token");
browser.Show();
//runtime error occurs on following line
currentUrl = browser.Url.ToString();
browser.Url = new Uri("http://www.yahoo.com");
browser.Navigated += new WebBrowserNavigatedEventHandler(checkForToken);
this.Controls.Add(browser);
}
private void checkForToken(object sender, EventArgs e)
{
MessageBox.Show(currentUrl);
}
}
}
如果没有完全的例外,我们不能不提供帮助。 –