設定編譯程式以 .NET Compact Framework 為目標。
語法
-netcf
備註
選項 -netcf 會使 Visual Basic 編譯程式以 .NET Compact Framework 為目標,而不是完整的 .NET Framework。 只有完整 .NET Framework 中出現的語言功能已停用。
此選項 -netcf 的設計目的是要與 -sdkpath 搭配使用。 所 -netcf 停用的語言功能與 目標檔案 -sdkpath中不存在的相同語言功能。
備註
此選項 -netcf 無法在Visual Studio開發環境中使用;只有在從命令行進行編譯時,才能使用此選項。 載入 Visual Basic 裝置專案時,會 -netcf 設定此選項。
選項 -netcf 會變更下列語言功能:
End <關鍵詞> Statement 關鍵詞會終止程序執行,已停用。 下列程式會編譯並執行 ,但
-netcf會在編譯時期使用-netcf失敗。Module Module1 Sub Main() End ' not valid to terminate execution with /netcf End Sub End Module所有形式的晚期系結都會停用。 當發現已辨識的晚期系結案例時,會產生編譯時間錯誤。 下列程式會編譯並執行 ,但
-netcf會在編譯時期使用-netcf失敗。Class LateBoundClass Sub S1() End Sub Default Property P1(ByVal s As String) As Integer Get End Get Set(ByVal Value As Integer) End Set End Property End Class Module Module1 Sub Main() Dim o1 As Object Dim o2 As Object Dim o3 As Object Dim IntArr(3) As Integer o1 = New LateBoundClass o2 = 1 o3 = IntArr ' Late-bound calls o1.S1() o1.P1("member") = 1 ' Dictionary member access o1!member = 1 ' Late-bound overload resolution LateBoundSub(o2) ' Late-bound array o3(1) = 1 End Sub Sub LateBoundSub(ByVal n As Integer) End Sub Sub LateBoundSub(ByVal s As String) End Sub End ModuleAuto、Ansi 和 Unicode 修飾詞已停用。 Declare 語句的語法也會修改為
Declare Sub|Function name Lib "library" [Alias "alias"] [([arglist])]。 下列程式代碼顯示 對編譯的影響-netcf。' compile with: /target:library Module Module1 ' valid with or without /netcf Declare Sub DllSub Lib "SomeLib.dll" () ' not valid with /netcf Declare Auto Sub DllSub1 Lib "SomeLib.dll" () Declare Ansi Sub DllSub2 Lib "SomeLib.dll" () Declare Unicode Sub DllSub3 Lib "SomeLib.dll" () End Module使用從 Visual Basic 移除的 Visual Basic 6.0 關鍵詞,會在使用 時
-netcf產生不同的錯誤。 這會影響下列關鍵詞的錯誤訊息:OpenClosePutPrintWriteInputLockUnlockSeekWidthNameFreeFileEOFLocLOFLine
範例
下列程式代碼會 Myfile.vb 使用 .NET Compact Framework 編譯,並使用 C 磁碟驅動器上 .NET Compact Framework 的預設安裝目錄中找到的 mscorlib.dll 和 Microsoft.VisualBasic.dll 版本。 一般而言,您會使用最新版的 .NET Compact Framework。
vbc -netcf -sdkpath:"c:\Program Files\Microsoft Visual Studio .NET 2003\CompactFrameworkSDK\v1.0.5000\Windows CE " myfile.vb