/netcf
Sets the compiler to target the .NET Compact Framework.
/netcf
Remarks
The /netcf option 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.
The /netcf option 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
The /netcf option is not available from within the Visual Studio development environment; it is available only when compiling from the command line. The /netcf option is set when a Visual Basic device project is loaded.
The /netcf option changes the following language features:
The End (Visual Basic) keyword, which terminates execution of a program, is disabled. The following program compiles and runs without /netcf but fails at compile time with /netcf.
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 compiles and runs without /netcf but fails 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 ' 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 Module
The Auto, Ansi, and Unicode (Visual Basic) modifiers are disabled. The syntax of the Declare Statement statement is also modified to Declare Sub|Function name Lib "library" [Alias "alias"] [([arglist])]. The following code 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" () ' 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
Using Visual Basic 6.0 keywords that were removed from Visual Basic generates a different error when /netcf is used. This affects the error messages for the following keywords:
Open
Close
Put
Print
Write
Input
Lock
Unlock
Seek
Width
Name
FreeFile
EOF
Loc
LOF
Line
Example
The following code compiles Myfile.vb with the .NET Compact Framework, using the versions of Mscorlib.dll and Microsoft.VisualBasic.dll found in the default installation directory of the .NET Compact Framework on the C drive. Typically, you would use the most recent version of the .NET Compact Framework.
vbc /netcf /sdkpath:"c:\Program Files\Microsoft Visual Studio .NET 2003\CompactFrameworkSDK\v1.0.5000\Windows CE " myfile.vb
See Also
Reference
Sample Compilation Command Lines