Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
简单的C#WPF表单生成大量看似无意义的错误消息_C#_Wpf_Visual Studio 2008 - Fatal编程技术网

简单的C#WPF表单生成大量看似无意义的错误消息

简单的C#WPF表单生成大量看似无意义的错误消息,c#,wpf,visual-studio-2008,C#,Wpf,Visual Studio 2008,下面的代码包含“一大堆”错误消息,我一辈子都想不出原因。我最近不得不从VS2010“降级”到VS2008,从那以后我除了痛苦什么都没有。前几条错误消息在发生位置旁边显示为注释 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Da

下面的代码包含“一大堆”错误消息,我一辈子都想不出原因。我最近不得不从VS2010“降级”到VS2008,从那以后我除了痛苦什么都没有。前几条错误消息在发生位置旁边显示为注释

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;

namespace UniClient_NextGen
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }

        private void buttonPopMenuItemsLU_Click(object sender, RoutedEventArgs e) 
        { // err msg #1 = "} expected"
            public static int TOPLEVEL_ID = 0;
            public static int PARENT_ID = 1;
            public static int SELF_ID = 2;
            public static int MENU_CAPTION = 3;
            public static int MENU_NAME = 4;

            string fileName = @"C:\_UniClientNextGen\MenuItemsWithIDs.txt";
            using (StreamReader reader = File.OpenText(fileName)) // err msg #2 = "Invalid token 'using' in class, struct, or interface member declaration" + err msg #3 = "; expected" (at end of this line)
            {
                string _line = null;
                string[] strElements;
                do
                {
                    _line = reader.ReadLine();
                    strElements = _line.Split(",");
                    // strElements should now have five elements
                    int iTopLevelID = Convert.ToInt32(strElements[TOPLEVEL_ID]);
                    int iParentID = Convert.ToInt32(strElements[PARENT_ID]);
                    int iOwnID = Convert.ToInt32(strElements[SELF_ID]);
                    string sMenuCaption = strElements[MENU_CAPTION];
                    string sMenuName = strElements[MENU_NAME];
                    //performSQL("INSERT INTO MENU_ITEMS_LOOKUP (TopLevelMenuID, ParentMenuID, MenuItemName, MenuItemCaption) VALUES (iTopLevelID, iParentID, iOwnID, sMenuCaption, sMenuName)");
                } while (_line != null);
            }
        } // err msg #4 = "Type or namespace definition, or end-of-file expected" 

        private void buttonPopSorterTypesLU_Click(object sender, RoutedEventArgs e)
        {
            //
        }

        private void buttonPopTabsheetsLU_Click(object sender, RoutedEventArgs e)
        {
            //
        }

        private void buttonPopMenuItem_SorterTypeM2M_Click(object sender, RoutedEventArgs e)
        {
            //
        }

        private void buttonPopSorterType_TabsheetM2M_Click(object sender, RoutedEventArgs e)
        {
            //
        }
    }
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用System.Windows;
使用System.Windows.Controls;
使用System.Windows.Data;
使用System.Windows.Documents;
使用System.Windows.Input;
使用System.Windows.Media;
使用System.Windows.Media.Imaging;
使用System.Windows.Navigation;
使用System.Windows.Shapes;
使用System.IO;
命名空间UniClient_NextGen
{
/// 
///Window1.xaml的交互逻辑
/// 
公共部分类Window1:Window
{
公共窗口1()
{
初始化组件();
}
私有无效按钮nPMenuItemsLu_单击(对象发送者,路由目标)
{//err msg#1=“}应为”
公共静态int顶级_ID=0;
公共静态int PARENT_ID=1;
公共静态int SELF_ID=2;
公共静态int菜单_标题=3;
公共静态int菜单_NAME=4;
字符串文件名=@“C:\\U UniclientTextGen\MenuItemsWithIDs.txt”;
在类、结构或接口成员声明中使用(StreamReader reader=File.OpenText(fileName))//err msg#2=“无效令牌”using“+err msg#3=“;预期”(在此行末尾)
{
字符串_line=null;
字符串[]元素;
做
{
_line=reader.ReadLine();
strElements=_line.Split(“,”);
//元素现在应该有五个元素
int iTopLevelID=Convert.ToInt32(strElements[TOPLEVEL_ID]);
int-iParentID=Convert.ToInt32(strElements[PARENT_ID]);
int iOwnID=Convert.ToInt32(strElements[SELF_ID]);
字符串sMenuCaption=strElements[MENU_CAPTION];
字符串smenuame=strElements[菜单名称];
//performSQL(“插入菜单项查找(TopLevelMenuID、ParentMenuID、MenuItemName、MenuItemCaption)值(iTopLevelID、iParentID、iOwnID、sMenuCaption、sMenuName)”;
}while(_line!=null);
}
}//err msg#4=“需要类型或命名空间定义,或文件结尾”
私有无效按钮PSORTERTYPESLU\U单击(对象发送方,路由目标)
{
//
}
私有无效按钮父表lu_单击(对象发送者,路由目标e)
{
//
}
私有无效按钮pMenuItem\u SorterTypeM2M\u单击(对象发送方,路由目标)
{
//
}
私有无效按钮PSORTERTYPE\选项卡表单M2M\单击(对象发送者,路由目标e)
{
//
}
}
}

为什么在方法内部有
公共静态
声明?

为什么在方法内部有
公共静态
声明?

我认为您是XAML定义,或者XAML命名空间与类不同步。最近是否重命名了类或命名空间

我认为您的XAML定义不正确,或者XAML命名空间与您的类不同步。最近是否重命名了类或命名空间

下面是更正的代码(我已将静态成员声明移到正确的位置,并更正了_line.Splt()参数):


下面是更正的代码(我已将静态成员声明移到正确的位置,并更正了_line.Splt()参数):


当您在VS2010中使用该项目时,该项目是什么.NET版本,之前是什么,现在是什么?这是一个全新的项目,创建于VS2008中.NET 3.5 SP1当您在VS2010中使用该项目时,该项目是什么.NET版本,之前是什么,现在是什么?这是一个全新的项目,创建于VS2008中.NET 3.5 SP1No;它是:不;这是:完全考-错误的静态和错误的引用字符造成所有的混乱!全考-错误的静态和错误的引用字符造成所有的混乱!
//...
public static int TOPLEVEL_ID = 0;
public static int PARENT_ID = 1;
public static int SELF_ID = 2;
public static int MENU_CAPTION = 3;
public static int MENU_NAME = 4;

void buttonPopMenuItemsLU_Click(object sender, RoutedEventArgs e) {
    string fileName = @"C:\_UniClientNextGen\MenuItemsWithIDs.txt";
    using(StreamReader reader = File.OpenText(fileName)) {
        string _line = null;
        string[] strElements;
        do {
            _line = reader.ReadLine();
            strElements = _line.Split(',');
            int iTopLevelID = Convert.ToInt32(strElements[TOPLEVEL_ID]);
            int iParentID = Convert.ToInt32(strElements[PARENT_ID]);
            int iOwnID = Convert.ToInt32(strElements[SELF_ID]);
            string sMenuCaption = strElements[MENU_CAPTION];
            string sMenuName = strElements[MENU_NAME];
        } while(_line != null);
    }
}
//...