日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

dNet命令行编译命令CSC使用详细图解

發布時間:2025/4/14 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 dNet命令行编译命令CSC使用详细图解 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

下面先給出編譯示例的代碼;

add.cs

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace TestClaclulate { class Program { static void Main(string[] args) { // 1,定義double變量 double numberOne; double numberTwo; // 2,從控制臺獲得兩個數 try { numberOne = double.Parse(Console.ReadLine()); numberTwo = double.Parse(Console.ReadLine()); // 3,輸出這兩個數的加,減,乘,除 的結果 Console.WriteLine(numberOne + " + " + numberTwo + " = " + (numberOne + numberTwo)); Console.WriteLine(numberOne + " - " + numberTwo + " = " + (numberOne - numberTwo)); Console.WriteLine(numberOne + " * " + numberTwo + " = " + (numberOne * numberTwo)); Console.WriteLine(numberOne + " / " + numberTwo + " = " + (numberOne / numberTwo)); } catch (System.FormatException e) { Console.WriteLine(e.Message); } // Console.ReadKey(); } } }
main.cs

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using 讀寫ini文件;class Program{static void Main(string[] args){string Current;Current = Directory.GetCurrentDirectory();//獲取當前根目錄Console.WriteLine("Current directory {0}", Current);// 寫入iniIni ini=new Ini(Current+"/config.ini");ini.Writue("Setting","key1","hello word!");ini.Writue("Setting","key2","hello ini!");ini.Writue("SettingImg", "Path", "IMG.Path");// 讀取inistring stemp = ini.ReadValue("Setting","key2");Console.WriteLine(stemp); Console.ReadKey();} }


inioper.cs


using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO;namespace 讀寫ini文件 {public class Ini{// 聲明INI文件的寫操作函數 WritePrivateProfileString()[System.Runtime.InteropServices.DllImport("kernel32")]private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);// 聲明INI文件的讀操作函數 GetPrivateProfileString()[System.Runtime.InteropServices.DllImport("kernel32")]private static extern int GetPrivateProfileString(string section, string key, string def, System.Text.StringBuilder retVal, int size, string filePath);private string sPath = null;public Ini(string path){this.sPath = path;}public void Writue(string section, string key, string value){// section=配置節,key=鍵名,value=鍵值,path=路徑WritePrivateProfileString(section, key, value, sPath);}public string ReadValue(string section, string key){// 每次從ini中讀取多少字節System.Text.StringBuilder temp = new System.Text.StringBuilder(255);// section=配置節,key=鍵名,temp=上面,path=路徑GetPrivateProfileString(section, key, "", temp, 255, sPath);return temp.ToString();}} }


首先設置csc所在目錄到path環境變量;

編譯第一個cs文件,執行情況如下;



編譯為dll,第一次代碼中少了一個大括號,第二次成功;編譯后的dll見下圖;



編譯add.cs為my.exe;編譯和執行情況如下;



通過使用優化和定義 DEBUG 符號,編譯當前目錄中所有的 C# 文件;

第一次代碼中少了一個大括號;

第二次缺少命名空間引用;第三次main.cs缺少對inioper的命名空間引用;

第四次成功;



執行情況;



/define 選項的效果與在源文件中使用 #define 預處理器指令一樣。符號一直保持定義到源文件中的 #undef 指令移除定義,或者編譯器執行到文件尾。
參見
https://msdn.microsoft.com/zh-cn/library/0feaad6z(VS.80).aspx

一個示例的代碼和執行情況如下;

// preprocessor_define.cs // compile with: /define:xx // or uncomment the next line #define xx using System; public class Test {public static void Main() {#if (xx) Console.WriteLine("xx defined");#elseConsole.WriteLine("xx not defined");#endif} }



使用響應文件;編譯命令存在響應文件中;#開頭的行在rsp文件中是注釋;

resp1.rsp

# 這是一個簡單的響應文件,文件名稱為resp1.rsp # 使用方法: csc @resp1.rsp /target:exe /out:respadd.exe add.cs


使用響應文件編譯的情況如下圖;第一次忘了打@符號;



執行情況,跟csc直接編譯的一樣;



編譯為DLL時指定DLL載入首選基地址;編譯情況如下圖;




用PEInfo打開上述DLL,看紅線處,優先裝載地址是在編譯命令中指定的;



編譯時把bug信息輸出的一個文件中;



打開debug開關,將會生成pdb文件;



編譯時同時為應用程序生成一個xml文檔;



增量編譯,按網上資料打的命令,提示出錯,下次再搞;增量編譯是僅僅編譯改變后的代碼,同時生成.incr文件;



編譯時指定一個圖標;如下圖,編譯后的應用程序將具有一個圖標;




相關鏈接:

http://wuyisky.cnblogs.com/archive/2007/07/03/804157.html

http://www.cnblogs.com/shuang121/archive/2012/12/24/2830874.html


總結

以上是生活随笔為你收集整理的dNet命令行编译命令CSC使用详细图解的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。