Hidden Improvements in Visual Basic 11

Hi All,

I want to share perfect essay in my Visual Basic .NET Blog.
If any question you have, pls feel free to contact me.


By Joe Kunk 04/20/2012
In my January article "Visual Basic Improvements in Visual Studio 11," I presented the major enhancements to Visual Basic 11 that appear in the Visual Studio 11 Beta. Key improvements include the Async and Await keywords, Iterators, Call Hierarchy and the Global keyword.

In February, I attended the 2012 Microsoft Global MVP Summit in Redmond. At the event, Microsoft Visual Basic Program Manager Lucian Wischik presented a four page list of enhancements in Visual Basic 11. Here are a few of the best VB11 updates from his list, enhancements that you may not have noticed.

MSTest and XUnit now support Async and Await in unit tests. Prior to this support, the test method did not wait for the Await method to complete, potentially executing the Assert method too soon. Now, the Async method will complete and the Assert behaves as expected.

Security is enhanced to ensure that any framework method that delay-executes a delegate, does so in the proper SecurityContext. The number of heap allocations is reduced, which benefits server scalability.

Compiler Switches 
The compiler switch "/vbruntime:*" embeds core functionality from the Visual Basic Runtime Library into your assembly to provide useful Visual Basic functions without requiring a reference to the runtime library. This new functionality opens Visual Basic to target platforms that do not support the Visual Basic runtime like the Portable Library, XNA, Windows Phone and the Micro Framework. With this switch, any use of Visual Basic features outside the embedded core functionality will result in a compiler error.
The compiler switch "/platform: anycpu32bitpreferred" was added as a better alternative to the AnyCPU setting. Many developers change the default Target CPU from x86 to AnyCPU, thinking that will provide optimum performance in both x86 and x64 operating system (OS) environments. However, the performance penalty for running 64-bit code is rarely worth it. It's justified only when large memory space is truly needed. The vast majority of applications will run faster as 32-bit applications, even in a 64-bit OS. This new compiler switch favors the benefits of x86 on an Intel CPU, but still permits deployment to other CPUs such as ARM. Note that due to a bug in VB11, this option is not available in Visual Studio's Project Properties Compile tab Target CPU field, it can only be set with the vbc.exe command line compiler.

The compiler switch "/highentropyva" marks the assembly header with a flag instructing the OS to perform additional randomization of the memory layout of the executable, making it less vulnerable to some security attacks. This switch is on by default.

Optional Parameter Overloads 
The following overloads are now legal in VB11. In VB10, they generate the error message shown in Figure 1.
  Private Sub f(x As Integer)
           End Sub  Private Sub f(x As Integer,
           Optional y As Integer = 0)  End Sub

Figure 1. Visual Studio 2010 overloads error removed in Visual Studio 11 Beta

Read-Only Types
Three read-only types were added to the .NET Framework for compatibility with WinRT applications: IReadOnlyCollecton(Of T), IReadOnlyList(Of T) and IReadOnlyDictionary(Of K,V). Sample code to initialize the three structures is as follows:

  Private Sub NewVB11Types()
   'Initialize the ReadOnlyCollection from a mutable collection  
   Dim VSMAuthors As New List(Of String)(New String() {      
   "Brust", "Kunk", "Nasr", "Papa", "Steele", "Vogel"})  
   Dim VSMColumns As New Dictionary(Of String, String) From {      
   {"C# Corner", "bit.ly/HF0unQ"}, {"On VB", "bit.ly/HcVWmO"}}  
   Dim roc As New System.Collections.ObjectModel.ReadOnlyCollection(Of String)(VSMAuthors)  
   Dim rol As System.Collections.Generic.IReadOnlyList(Of String) = VSMAuthors  
Dim rod As System.Collections.Generic.IReadOnlyDictionary(Of String, String) = VSMColumns
End Sub

Type Inference for Return Array Literals 
Visual Basic 11 extends type inference to array literals as shown in the following code. In Visual Studio 2010, the "Return {}" statement would have been typed as an Object array incompatible with the required return type of Integer array and generated the error shown in Figure 2 . Under Visual Studio 11, this sample code builds fine.
  Function f(i As Integer) As Integer()    
   If i = 0 Then Return {}    
   Return {1, 2, 3}  End Function

Bug Fixes 
Nearly 200 bugs were fixed in Visual Studio 11, including many situations that caused Visual Studio to crash: error reporting, closing a project, referencing an obfuscated assembly, using NoPIA (type embedding) and huge string concatenation. Visual Studio 2010 was the first release of the WPF-based user interface, so these crash bugs were not unexpected, and they were quickly addressed.

How can you best report errors and enhancement suggestions to Microsoft to help improve future versions of Visual Studio and the .NET languages? If there is a crash, allow the Watson report of the crash to be sent to Microsoft. These reports are aggregated, and the ones that occur most frequently get automatically created as bugs.

Bugs are sometimes drawn from StackOverflow or from blogs, but this is not a reliable way to get Microsoft's attention. It's better to file your bug or enhancement idea on Microsoft Connect or the Visual Basic Language forum. These sites get the greatest attention from Microsoft.

Explore the Visual Basic 11 Beta
I've listed just some of the lesser known improvements in the Visual Basic 11 Beta. If you have not done so already, download your copy of the Windows 8 Consumer Preview and the Visual Studio 11 Beta. I'm sure you'll enjoy these enhancements and find even more language goodies than I've discussed here.


DNS Class

Method of the DNS 


Asynchronously returns the Internet Protocol (IP) addresses for the specified host.


 Obsolete. Begins an asynchronous request for IPHostEntry information about the specified DNS host name.

BeginGetHostEntry(IPAddress, AsyncCallback, Object)

Asynchronously resolves an IP address to an IPHostEntry instance.

BeginGetHostEntry(String, AsyncCallback, Object)

Asynchronously resolves a host name or IP address to an IPHostEntry instance.


 Obsolete. Begins an asynchronous request to resolve a DNS host name or IP address to an IPAddress instance.


Ends an asynchronous request for DNS information.


 Obsolete. Ends an asynchronous request for DNS information.


Ends an asynchronous request for DNS information.


 Obsolete. Ends an asynchronous request for DNS information.


Returns the Internet Protocol (IP) addresses for the specified host.


 Obsolete. Creates an IPHostEntry instance from the specified IPAddress.


 Obsolete. Creates an IPHostEntry instance from an IP address.


 Obsolete. Gets the DNS information for the specified DNS host name.


Resolves an IP address to an IPHostEntry instance.


Resolves a host name or IP address to an IPHostEntry instance.


Gets the host name of the local computer.


 Obsolete. Resolves a DNS host name or IP address to an IPHostEntry instance.

Have a nice day
Yener Turkeli 


Hi Everybody,
I would like to explain one of faq within this essay , how we can
use DNS Function    via VB.NET Windows Application.
I am going to explain it with VB.NET 2010.

If any question, please feel free to contact me y_turkeli@yahoo.com or

The Dns class is a static class that retrieves information about a specific host from the Internet Domain Name System (DNS).

1-) We are creating a new Windows Application Project

2-) We are designing this windows form in a similar way to the picture below

3-) We are writing this code

Imports System.Net

Public Class Form1

    Private Sub dns_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dns_btn.Click
        Dim hostInfo As IPHostEntry = Dns.GetHostByName(address_txt.Text)

        Label1.Text = hostInfo.AddressList(0).Address
    End Sub
End Class

4-) Lets run the application

Lets run the application

Have a nice day
Yener Turkeli