C# winform程序 使用控制台输出无结果?
Program代码如下:
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
internal static class Program
{
public delegate int NumberAdd(int a, int b);
///
/// 启动控制台
///
/// <returns></returns>
[DllImport("kernel32.dll")]
public static extern Boolean AllocConsole();
///
/// 释放控制台
///
/// <returns></returns>
[DllImport("kernel32.dll")]
public static extern Boolean FreeConsole();
///
/// 应用程序的主入口点。
///
///
[STAThread]
static void Main(string[] args)
{
AllocConsole();//调用系统API,调用控制台窗口
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new WindowsFormsApp1.Form1());
Console.WriteLine("Hello World!");
Console.ReadKey();
FreeConsole();
}
}
运行结果如下:
没有 FrmMain 类?
别人代码里是这样写的:
Application.Run(new FrmMain());
我找不到FrmMain这个类,所以写的项目自动生成的窗口类。
不支持Action.BeginInvoke(null, null)的委托异步调用方法?
最近在学异步编程,使用 IAsyncResult iAsyncResult = numberAdd.BeginInvoke(2, 5, null, null); 时程序就报错此平台不支持操作,试了一下发现只有..net framework可以运行,而.net winform程序同样报错。想问问以后开发程序也报错怎么办?