| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1928 人关注过本帖
标题:[求助] 代码生成时出现这样的问题
只看楼主 加入收藏
yuyongquan
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2005-2-18
收藏
 问题点数:0 回复次数:3 
[求助] 代码生成时出现这样的问题

以下是代码:(后面是调试,生成,设计窗口下对应的结果,我不知道是什么地方的问题,所以全部贴出来了。请知道的帮忙看看是什么地方的问题。先谢谢了!)

using System;

namespace ConsoleApplicationl
{
///<summary>
///Summary description for Class1.
///</summary>
class Class1
{
static void Main(string[]args)
{
//
//TODO:Add code to start application here
// static void Main(string[]args)
Console.WriteLine("The first app in Beginning C# Programming!");
}
}
}




设计窗口提示:

文件中的类都不能进行设计,因此未能为该文件显示设计器。设计器检查出文件中有以下类:
Class1 --- 无法设计基类“System.Object”。


生成:
------ 已启动生成: 项目: WindowsService1, 配置: Debug .NET ------

正在准备资源...
正在更新引用...
正在执行主编译...

生成完成 -- 0 个错误,0 个警告
正在生成附属程序集...

---------------------- 完成 ---------------------

生成: 1 已成功, 0 已失败, 0 已跳过


调试:
“DefaultDomain”: 已加载“c:\windows\microsoft.net\framework\v1.1.4322\mscorlib.dll”,未加载符号。
“WindowsService1”: 已加载“G:\C#\WindowsService1\bin\Debug\WindowsService1.exe”,符号已加载。
The first app in Beginning C# Programming!
程序“[740] WindowsService1.exe”已退出,返回值为 0 (0x0)。



搜索更多相关主题的帖子: 代码 
2006-05-06 20:16
marer
Rank: 2
等 级:新手上路
威 望:3
帖 子:928
专家分:0
注 册:2005-7-18
收藏
得分:0 

using System;

namespace ConsoleApplication1
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: 在此处添加代码以启动应用程序
//
}
}
}

看看有什么不一样的?自己对吧


public class 人生历程 extends Thread{public void run(){while(true){努力,努力,再努力!!;Thread.sleep(0);}}}
2006-05-07 10:29
yuyongquan
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2005-2-18
收藏
得分:0 

我如果选择‘控制台应用程序’摸版调试这段代码可以运行成功。如果选择‘Windows 服务’摸版调试代码就回出现上面的问题。我还想请教一下如果运行小段的C#程序应该选择哪种摸版?谢谢!

2006-05-07 10:49
ca1194755213
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-6-29
收藏
得分:0 
using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using


namespace Notepad
{
    public partial class Form1 : Form
    { /// <summary>
        /// 必需的设计器变量。
        /// </summary>
        private compon = null;

        /// <summary>
        /// 清理所有正在使用的资源。
        /// </summary>
        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (compon != null))
            {
                compon.Dispose();
            }
            base.Dispose(disposing);
        }
      
       // Windows 窗体设计器生成的代码
      
        public System.Windows.Forms.TextBox textBox1;
        private System.Windows.Forms.MenuStrip menuStrip1;
        private System.Windows.Forms.ToolStripMenuItem 文件ToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem 打开ToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem 保存ToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem 另存为ToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem 退出XToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem 编辑ToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem 格式ToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem 查看ToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem 帮助HToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem 新建ToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem 撤销ToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem 剪切TToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem 复制CToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem 粘贴VToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem 删除DToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem 全选ToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem 日期时间F5ToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem 帮助主题ToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem 关于记事本ToolStripMenuItem;
        private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
        private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
        private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
        private System.Windows.Forms.ToolStripMenuItem 自动换行OToolStripMenuItem;
        private System.Windows.Forms.ToolStripMenuItem 字体ToolStripMenuItem;
        internal System.Windows.Forms.StatusStrip StatusStrip1;
        internal System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
        internal System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel2;
        private System.Windows.Forms.Timer timer1;
        private System.Windows.Forms.ToolStripMenuItem 状态栏SToolStripMenuItem;
        private System.Windows.Forms.ColorDialog colorDialog1;
        private System.Windows.Forms.FontDialog fontDialog1;
        private System.Windows.Forms.ToolStripMenuItem 字体颜色ToolStripMenuItem;
    }

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
         private bool b = false;
        public string str_old;
        public string file_old;
        public string file;
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            b = true;
        }

        private void 新建NToolStripMenuItem_Click(object sender, EventArgs e)
        {
            new Form1().Show();
        }

        private void 打开SToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog of = new OpenFileDialog();
            of.Filter = "文本文档(*.txt)|*.txt";
            if (textBox1.Text == str_old)
            {
                if (of.ShowDialog() == DialogResult.OK)
                {
                    file = of.FileName;
                    StreamReader sr = new StreamReader(file, Encoding.GetEncoding("GB2312"));
                    textBox1.Text = sr.ReadToEnd().ToString();
                    sr.Dispose();
                }
            }

            else
            {
                DialogResult = MessageBox.Show(this.Owner, file_old, "记事本", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); switch (DialogResult)
                {
                    case DialogResult.Yes:
                        SaveFileDialog sf = new SaveFileDialog();
                        sf.Filter = "文本文档(*.txt)|*.txt";
                        if (sf.ShowDialog() == DialogResult.OK)
                        {
                            StreamWriter sw = File.AppendText(sf.FileName);
                            sw.Write(textBox1.Text);
                            sw.Dispose();
                        }

                        break;
                    case DialogResult.No:
                        if (of.ShowDialog() == DialogResult.OK)
                        {
                            file = of.FileName;
                            StreamReader sr = new StreamReader(file, Encoding.GetEncoding("GB2312"));
                            textBox1.Text = str_old + sr.ReadToEnd().ToString();
                        }
                        break;
                    case DialogResult.Cancel:
                        return;
                    default:
                        return;

                }

            }
               

        }
        private void Form1_Load(object sender, EventArgs e)
        {
            str_old = textBox1.Text;
            file_old = "文件" + Application.ExecutablePath.Remove(Application.ExecutablePath.Length - 4, 4) + ".txt " + "的文字已经改变。\n\n 是否保存?";
        }
        private void 退出XToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (b)
            {
                if (MessageBox.Show("是否保存文档?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    保存SToolStripMenuItem_Click(sender, e);
                    this.Close();
                }
                else
                {
                    this.Close();//退出程序
                }
            }
            else
            {
                this.Close();//退出程序
            }

        }

        private void 保存SToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                StreamWriter sw = File.AppendText(Application.ExecutablePath);
                sw.Write(textBox1.Text);
                sw.Dispose();
            }
            catch
            {
                SaveFileDialog sf = new SaveFileDialog();
                sf.DefaultExt = "*.txt";
                sf.Filter = "文本文档(.txt)|*.txt";
                if (sf.ShowDialog() == DialogResult.OK)
                {
                    StreamWriter sw = File.AppendText(sf.FileName);
                    sw.Write(textBox1.Text);
                    sw.Dispose();
                }
            }

        }

        private void 另存为AToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog sf = new SaveFileDialog();
            sf.DefaultExt = "*.txt";
            sf.Filter = "文本文档(.txt)|*.txt";
            if (sf.ShowDialog() == DialogResult.OK)
            {
                StreamWriter sw = File.AppendText(sf.FileName);
                sw.Write(textBox1.Text);
                sw.Dispose();
            }
            new System.Windows.Forms.ToolStripSeparator();

        }

        private void 撤销ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            textBox1.Undo();
        }

        private void 复制ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Clipboard.SetText(textBox1.SelectedText);
        }

        private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text.Remove(textBox1.Text.Length - textBox1.SelectedText.Length, textBox1.SelectedText.Length);
            textBox1.Select(textBox1.Text.Length, 0);

        }

        private void 剪切ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Clipboard.SetDataObject(textBox1.SelectedText);
            textBox1.Text = textBox1.Text.Remove(textBox1.SelectionStart, textBox1.SelectionLength);
            textBox1.Select(textBox1.Text.Length, 0);

        }

        private void 粘贴ToolStripMenuItem_Click(object sender, EventArgs e)
        {
              textBox1.Text += Clipboard.GetText();
            textBox1.Select(textBox1.Text.Length, 0);

        }

        private void 全选ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            textBox1.SelectAll();
        }

        private void 日期时间ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int count = textBox1.Text.IndexOf(textBox1.SelectedText, textBox1.SelectionStart);
            textBox1.Text = textBox1.Text.Remove(textBox1.Text.IndexOf(textBox1.SelectedText, 0), textBox1.SelectedText.Length);
            textBox1.Select(count, 0);
            textBox1.Text = textBox1.Text.Insert(textBox1.SelectionStart, DateTime.Now.ToString());
            textBox1.Select(textBox1.Text.IndexOf(DateTime.Now.ToString(), 0) + DateTime.Now.ToString().Length, 0);

        }

        private void 自动换行ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            自动换行ToolStripMenuItem.Checked = !自动换行ToolStripMenuItem.Checked;
            if (自动换行ToolStripMenuItem.Checked)
            {
                textBox1.WordWrap = false;
            }
            else
            {
                textBox1.WordWrap = true;
            }

        }

        private void 字体ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FontDialog fd = new FontDialog();
            if (fd.ShowDialog() == DialogResult.OK)
            {
                textBox1.Font = fd.Font;
            }

        }

        private void 字体颜色ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            colorDialog1.Reset();
            colorDialog1.AllowFullOpen = true;
            if (colorDialog1.ShowDialog() == DialogResult.OK)
            {
                textBox1.ForeColor = colorDialog1.Color;
            }

        }

        private void 状态栏ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            状态栏ToolStripMenuItem.Checked = !状态栏ToolStripMenuItem.Checked;
            if (状态栏ToolStripMenuItem.Checked)
            {
                StatusStrip1.Visible = true;
            }
            else
            {
                statusStrip1.Visible = false;
            }

        }

        private void 帮助主题ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show("找不到帮助主题!", "提示");
        }

        private void 关于记事本ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show("联系记事本制作者 :1194755213@ ", "关于记事本");
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            MessageBox.Show("联系记事本制作者 :1194755213@ ", "关于记事本");
        }
    }
}



警告    1    类型 Form1 由同一文件中的几个分部类构成。        0    0
2013-06-29 00:35
快速回复:[求助] 代码生成时出现这样的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.034742 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved