A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

WPF程序Release生成提示:不包含适合于入口点的静态“Main方法,Debug生成沒有问题,求解释!{:soso_e150:}

3 个回复

倒序浏览
建议把主要的代码发出来方便分析。
既然是说不包含Main方法,那应该是代码中没有Main方法或者Main方法是空的没有调用你的主要方法吧。Main方法是整个程序的入口,相当于房子的大门,不走大门就不能进入其它房间。
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;

  6. namespace ConsoleApplication1
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             SayHello();
  13.         }

  14.         public static void SayHello()
  15.         {
  16.             Console.WriteLine("Hello World");
  17.             Console.ReadKey();
  18.         }
  19.     }
  20. }
复制代码
回复 使用道具 举报
黑骏马 发表于 2013-7-26 23:27
建议把主要的代码发出来方便分析。
既然是说不包含Main方法,那应该是代码中没有Main方法或者Main方法是空 ...

嗯,是wpf
回复 使用道具 举报
  1. <Window x:Class="WpfApplication1.MainWindow"
  2.         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3.         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4.         Title="MainWindow" Height="350" Width="525">
  5.     <Grid>
  6.         <Button x:Name="But1" Content="点我" HorizontalAlignment="Left" Height="40" Margin="200,150,0,0" VerticalAlignment="Top" Width="125" Click="OnClick"/>

  7.     </Grid>
  8. </Window>
复制代码
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;

  15. namespace WpfApplication1
  16. {
  17.     /// <summary>
  18.     /// MainWindow.xaml 的交互逻辑
  19.     /// </summary>
  20.     public partial class MainWindow : Window
  21.     {
  22.         public MainWindow()
  23.         {
  24.             InitializeComponent();
  25.             MakeButton();
  26.         }

  27.         public void MakeButton()
  28.         {
  29.             Button But1 = new Button();
  30.             But1.AddHandler(Button.ClickEvent, new RoutedEventHandler(OnClick));
  31.         }
  32.         public void OnClick(object sender, RoutedEventArgs e)
  33.         {
  34.             But1.Content = "Hello World !";
  35.         }
  36.     }
  37. }
复制代码
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马