找不到类型命名空间名称Form1

时间:2017-04-21 10:56:05

标签: c#

您好我的代码有问题我需要修复一个错误“无法找到类型命名空间名称Form1”任何帮助将不胜感激。

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.Threading;
using PS3Lib;

namespace xpartygo
{
    public partial class Form1 : Form
    {
        private PS3API PS3 = new PS3API();
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                PS3.ConnectTarget();
                PS3.AttachProcess();
                MessageBox.Show("Connected!");
                button3.Enabled = true;
                button2.Enabled = true;
                PS3.Extension.WriteUInt32(0x3DBD54, 0x480000D8); // Disable Cheat Protection
            }
            catch
            {
                MessageBox.Show("Failed to connect!");
            }
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            PS3.ChangeAPI(SelectAPI.TargetManager);
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            PS3.ChangeAPI(SelectAPI.ControlConsole);
        }

        public void Cbuf_AddText(string text)
        {
            PS3.Extension.WriteString(0x10075000, text); // Write Command Input
            PS3.SetMemory(0x37F80, new byte[] { 0xF8, 0x21, 0xFF, 0x91, 0x7C, 0x08, 0x02, 0xA6, 0xF8, 0x01, 0x00, 0x80, 0x38, 0x60, 0x00, 0x00, 0x3C, 0x80, 0x10, 0x07, 0x30, 0x84, 0x50, 0x00, 0x48, 0x2D, 0xBC, 0x81, 0xE8, 0x01, 0x00, 0x80, 0x7C, 0x08, 0x03, 0xA6, 0x38, 0x21, 0x00, 0x70, 0x4E, 0x80, 0x00, 0x20 }); // Cbuf_AddText RPC
            Thread.Sleep(100);
            PS3.SetMemory(0x37F80, new byte[] { 0xF8, 0x21, 0xFE, 0xD1, 0x7C, 0x08, 0x02, 0xA6, 0xF8, 0x01, 0x01, 0x40, 0xDB, 0x21, 0x00, 0xF8, 0xDB, 0x41, 0x01, 0x00, 0xDB, 0x61, 0x01, 0x08, 0xDB, 0x81, 0x01, 0x10, 0xDB, 0xA1, 0x01, 0x18, 0xDB, 0xC1, 0x01, 0x20, 0xDB, 0xE1, 0x01, 0x28, 0xFB, 0xE1, 0x00, 0xF0 }); // Restore CG_DrawFPS Function
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Cbuf_AddText("party_connectToOthers 0;partyMigrate_disabled 1;party_mergingEnabled 0;xpartygo");
            MessageBox.Show("Has been executed!", "xpartygo", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Cbuf_AddText("reset party_connectToOthers;partyMigrate_disabled;party_mergingEnabled");
            MessageBox.Show("Has been executed!", "Dvar Reset", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
    }
}

我认为这是命名空间:

1 个答案:

答案 0 :(得分:0)

如果您提到的行System.Windows.Forms.Application.Run(new Form1());位于xpartygo的不同命名空间中的文件中,则需要将其编辑为System.Windows.Forms.Application.Run(new xpartygo.Form1());以对命名空间进行排序。

或者,将带有上述行的文件放入同一名称空间。

将来,将完全错误消息粘贴为编译器的输出,以及它引用的任何代码,使得想要帮助的人的生活变得更加轻松 - 这使您的生活更轻松: )

如果问题是对命名空间缺乏了解,请参阅here以获取更多信息。

编辑以回应评论: 很酷,我们都从某个地方开始 - 如果类A位于同一名称空间中,则类A只能“看到”类B,或者类A具有引用类B所在的命名空间的using语句。

它就像一个文件夹结构,你只能看到你当前所在的目录/ classes中的文件/ namespace,除非你查找/ using另一个文件夹/ {{ 1}}。

一个类'命名空间由它内部的namespace块定义。上面的链接应该比我更详细地解释所有这些。

您的问题可能是您在不同的命名空间中有两个类,而另一个正在尝试访问另一个。除非你正确处理这个问题,否则通过“查找”相应的命名空间,你会得到你看到的编译错误。