Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
449 views
in Technique[技术] by (71.8m points)

visual studio 2012 - Cant add system.windows.froms without could not be resolved error

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 AssembliesMicrosoftFramework.NETFrameworkv4.0System.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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...