Cant add system.windows.froms without could not be resolved error

一曲冷凌霜 提交于 2019-12-13 06:15:37

问题


I am a newbie to visual studio so apologies in advance for anything dumb I ask or say.

I am trying to inject a username and password into a document and automatically sign in to a https web site.

I use the code as follows:

 using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using System.Windows.Forms;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using TasKey2.Resources;
using System.IO.IsolatedStorage;

namespace myapp
{
public partial class MainPage : PhoneApplicationPage
{
    bool isLoggedOn = true;

    private string splashScreen = "https://xxxxxxt";
    private string teamScreen = "https://xxxxxxx";
    private string mainUrl;
    private string username, password;
    private bool loggedOn;
    System.Windows.Forms.WebBrowser webBrowser;
......

   private void Browser_Loaded(object sender, RoutedEventArgs e)
    {
        Browser.IsScriptEnabled = true;

        if (isLoggedOn)
        {
            mainUrl = teamScreen;
            Browser.Navigate(new Uri(mainUrl, UriKind.Absolute));

            HtmlElement userName = webBrowser.Document.GetElementById("Login1_UserName");
            userName.SetAttribute("value", username);
            userName.RemoveFocus();

            HtmlElement passWord = webBrowser.Document.GetElementById("Login1_Passwrod");
            passWord.SetAttribute("value", password);

            HtmlElement logonForm = webBrowser.Document.GetElementById("Login1_LoginButton");
            logonForm.InvokeMember("click");

        }

When I do I get the following error:

Error 1 The type or namespace name 'Forms' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) Error 2 The type or namespace name 'Forms' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?)
Error 3 The type or namespace name 'NavigateEventHandler' could not be found (are you missing a using directive or an assembly reference?)

SO I go to the Object Browser and can add System.Windows.Forms v2 and v4

Regardless of which one I addd I now get the following error:

Error 2 The base class or interface 'System.ComponentModel.Component' in assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' referenced by type 'System.Windows.Forms.Control' could not be resolved c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Windows.Forms.dll

I am banging my head against a bring wall on this. How do I add the System.Windows.Forms to my code and make it work?

来源:https://stackoverflow.com/questions/19308499/cant-add-system-windows-froms-without-could-not-be-resolved-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!