Net下的 jsc 和 csc 两个编译器

.Net下的 jsc 和 csc 两个编译器

JScript.Net 写一个窗口程序

import Accessibility;
import System;
import System.Windows.Forms;
import System.Drawing;
import System.Diagnostics;

package Client {
    public class Form1 extends Form {
        public function Form1() {
            InitializeComponent();
        }

        private function InitializeComponent() : void {
            this.Text = "Basic Windows Forms";
            this.Height = 400;
            this.Width = 500;
            this.WindowState = FormWindowState.Normal;
            this.StartPosition = FormStartPosition.CenterScreen;
            this.ProcessStart();
        }

        public function ProcessStart() {
            // 启动一个外部进程
            var startInfo = new ProcessStartInfo("java.exe");
            startInfo.UseShellExecute = false;
            startInfo.CreateNoWindow = false;
            Process.Start(startInfo);
        }
    }
}

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Client.Form1());

写一个build.bat来编译写好的.js文件

@set fileName=%1
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\jsc.exe /t:winexe /autoref %1
@if %errorlevel% EQU 0 (%fileName:~0,-3%.exe) else (ping 127.0.0.1 -n 3 >nul)

再来一个c#创建窗体的程序

using System;
using System.Windows.Forms;

namespace Client {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }
        
        private void InitializeComponent() {
            this.Text = "Basic Windows Forms";
            this.Height = 400;
            this.Width = 500;
            this.WindowState = FormWindowState.Normal;
            this.StartPosition = FormStartPosition.CenterScreen;
        }

        private void Form1_Load(object sender, EventArgs e) {
            MessageBox.Show("hello");
        }

        static void Main() {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}

同样写一个build.bat来编译写好的.cs文件

@set fileName=%1
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /t:winexe %1
@if %errorlevel% EQU 0 (%fileName:~0,-3%.exe) else (ping 127.0.0.1 -n 3 >nul)
posted @ 2019-12-27 21:22  noall  阅读(297)  评论(0)    收藏  举报