尝试在我正在编写的 Outlook 加载项中获取 WebBrowser 的 .Url 属性时出现“访问冲突”运行时错误。需要一些帮助来解决这个问题。研究表明我可能需要设置“FullTrust”权限集,但没有成功。
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);
}
}
}