Sets the compiler to target the .NET Compact Framework.
/netcf causes the Visual Basic compiler to target the .NET Compact Framework rather than the full .NET Framework. Language functionality that is present only in the full .NET Framework is disabled.
/netcf is designed to be used with /sdkpath. The language features disabled by /netcf are the same language features not present in the files targeted with /sdkpath.
Note /netcf is not available from within the Visual Studio .NET integrated development environment (IDE); it is available only when compiling from the command line. It cannot be changed programmatically. /netcf is set when a Visual Basic .NET device project is loaded.
/netcf disables the following features:
- The End keyword to terminate execution of a program:
Module Module1 Sub Main() End ' not valid to terminate execution with /netcf End Sub End Module
- Late binding, in all forms, is disabled. Compile-time errors are generated when recognized late-binding scenarios are encountered. The following program will compile and run without /netcf but will fail at compile time with /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 ' Latebound calls o1.S1() o1.P1("member") = 1 ' Dictionary member access o1!member = 1 ' Latebound overload resolution LateBoundSub(o2) ' Latebound array o3(1) = 1 End Sub Sub LateBoundSub(ByVal n As Integer) End Sub Sub LateBoundSub(ByVal s As String) End Sub End Module
- The Auto, Ansi, and Unicode modifiers are disabled. The syntax of the Declare statement is also modified to: Declare Sub|Function name Lib "library" [Alias "alias"] [([arglist])]. The following code sample shows the effect of /netcf on a compilation:
' compile with: /target:library Module Module1 ' valid with or without /netcf Declare Sub DllSub Lib "SomeLib.dll" () ' invalid 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
- The use of Visual Basic 6.0 keywords that were removed from Visual Basic .NET generate a different error when /netcf is used. This affects the error messages seen for the following keywords:
The following code compiles
myfile.vb with the .NET Compact Framework:
vbc /netcf myfile.vb