Aug 21

VB and C# enhancements in VS 2010I have found this post at somasegar’s blog writing about the new enhancements in VB and C# languages.

About VB.NET they include:
- removed the underscore (“_”) character when breaking a code statement across multiple lines
- simple way of declaring properties
- collection initializers and array literals are simpler as well
- better support for lambdas
- interoperating with dynamic language code such as Python and Ruby are simpler

Read also about C# improvements and find nice code samples here.

Jun 30

I am a VB!
Here is an interview with me at The Visual Basic Team blog.

Apr 17

Hi again, here are two free books as present from Microsoft for the 25th anniversary of Microsoft Press.

Windows Small Business Server 2008 Administrator's CompanionWindows Small Business Server 2008 Administrator’s Companion (24MB) by Charlie Russel and Sharon Crawford (27 chapters, 3 appendices, 712 pages)
Your comprehensive, one-volume guide to planning, setup, and administration. Get the critical information you need to build and run a Windows Small Business Server 2008–based network. This essential, single-volume reference details system capabilities and components—including Premium Edition features. Gain the real-world insights, workarounds, and troubleshooting tactics you need for on-the-job results.

Microsoft Visual Basic 2008 Express Edition: Build a Program Now!Microsoft Visual Basic 2008 Express Edition: Build a Program Now! (7.7MB) by Patrice Pelland (9 chapters, Glossary, 254 pages)
Make building new programming skills fun and fast with a quick-start, project-based approach!In this lively, eye-opening, hands-on book, all you need is a computer and the desire to learn how to program with Visual Basic 2008 Express Edition. Featuring a full edition of the software, this fun and highly visual guide walks you through a complete programming project—a desktop weather-reporting application—from start to finish. You’ll get an introduction to the Microsoft Visual Studio® development environment and learn how to put the lightweight, easy-to-use tools in Visual Basic Express Edition to work right away—creating, compiling, testing, and delivering your first ready-to-use program. You’ll get expert tips, coaching, and visual examples at each step of the way, along with pointers to additional learning resources.

Jan 21

I came across this article and really enjoyed it, thats why I have to share it with you. Written by Damon Armstrong this article gives a bit of light what is next in .NET field.

Co-Evolution for VB.NET and C#

One of the most prominent messages coming from Microsoft right now is geared towards Microsoft Visual Basic® .NET developers. VB.NET and Microsoft Visual C#® are both built on top of the Common Language Runtime (CLR), which means they both compile down into the same Common Intermediate Language (CIL). Since they both compile down to the same code, there should be no intrinsic benefit of one language over another. However, both languages are maintained by separate teams at Microsoft, and over the years this separation has led to a variety of language-specific features in both C# and VB.NET as the teams focus on different areas with their respective products. Many VB.NET developers feel that the most exciting new features appear in C# first and are only later introduced into VB.NET. Naturally, this has generated a bit of animosity in the VB.NET community.

Introducing the Dynamic Language Runtime

Microsoft is acutely aware that the .NET Framework is not the only choice for building applications. All you have to do is take a quick glance around the development sphere and you’ll find a number of language options, and that number is only expected to rise as domain-specific languages emerge. People are spending time and energy writing useful components in these languages, so the question is, how can you use a component written in another language without having to rewrite it in .NET?

At a high level, you can think of the Dynamic Language Runtime as having three layers (see figure 1 below):

* .NET Language Integration
* DLR Core Components
* Language Binders

The first layer, .NET Language Integration, simply represents the need for .NET languages to have a notion of what the DLR is and how to use it. For the most part, you won’t even notice this aspect of the DLR because most of the .NET languages had a natural integration point. IronRuby and IronPython are both dynamically typed languages, so the DLR fit right in. VB.NET has always supported the notion of late binding on the Object type, so the DLR incorporated nicely into late binding resolution. C#, however, has no notion of late binding and needed an additional static type for dynamic language support. It’s called the dynamic type, and we’ll talk about it in more detail a bit later.

Language Binders, which make up the third layer, are language-specific implementations of certain operations the Dynamic Language Runtime needs to understand about each language that wishes to participate in the DLR.

New Language Features in .NET 4.0
- Dynamic Lookup (New to C#)
- Named and Optional Parameters (New to C#)
- Anonymous Method Support (New to VB.NET)
- Co-variance and Contra-variance (New to C# and VB.NET)
- Dynamic Import (New to C#)
- Omitting Ref Parameters (New to C#)
- Compiling without Primary Interop Assemblies (New to C# and VB.NET)
- Implicit Line Continuation (New to VB.NET)
- Simplified Property Syntax (New to VB.NET)
- Array Type Inference and Jagged Arrays (New to VB.NET)
- From Keyword (New to VB.NET)

Functional Programming with F#

F# is a succinct, high performance, type-inferred, functional language built on top of the .NET Framework. Microsoft has a solid base of imperative programming languages with VB.NET and C#, but there is a trend in computing that tends to be moving towards a more declarative style of programming. What’s the difference? In an imperative language you write code that tells the compiler exactly how to do something, whereas in a declarative language you write code that says what you want to do, but leave the “how” part up to the compiler. Now, the ultimate declarative language would allow you to write something like “Morph the screen into something cool” and then compile your thoughts into a wicked screen saver or some such, but we’re not there just yet. F# offers developers the opportunity to explore declarative concepts and offer a useful language to customers whose thinking is geared more towards functional development.

Read the whole of this article from the source.

Jan 06

These are predictions by Guy Barrette who is Microsoft Regional Director.

ASP.NET is dead
You should drop ASP.NET and start using Silverlight right now because it is clear that Microsoft has no roadmap and future plans for that technology. At the last PDC, nothing new ASP.NET was announced except a few tweaks for AJAX and the fact that Microsoft released the MVC Framework proves that but IMHO, the MVC Framework is just a toy technology to shut the Agile loudmouths that wants to code everything by hand and reinvent the wheel.

BizTalk is dead
With Dublin coming up with the Framework 4.0, it makes no sense to purchase and invest in BizTalk anymore. Why spend gazillions of dollars when you’ll have the exact same services for free right in the Framework? Why being locked with a product when you get the API for free?

LINQ 2 SQL is dead
Microsoft recently stated that they have stopped working on LINQ 2 SQL to focus on the Entity Framework so why would you use LINQ 2 SQL anymore? Once again, Microsoft has released a new technology, people invested in that technology and Microsoft abandoned it without warnings. I’m not happy because I invested so much in LINQ 2 SQL so I think I’ll stick with ADO.NET fearing that Microsoft will eventually dropped the Entity Framework as well.

VB and C# are dead
At the last PDC, Microsoft showed Oslo, its modeling platform along with M, a modeling language. This will revolutionize the way we design and build applications. In the near future we will no longer code using low level languages like VB and C#. I would stop investing in these languages right now and train my whole team in M.

Azure is DOA
Cloud computing, talk about something so stupid its name is stupid. Why the heck would I push my apps and data in Microsoft’s data centers? I don’t get it and I think no one will use that technology and trust Microsoft. This thing is dead even before it will be released (.NET My Services anyone?).

OK, you must have seen similar comments everywhere in forums, blogs or talking with colleagues and other developers but is any of this making sense?

AP.NET vs Silverlight vs MVC Framework
When I was at the last PDC, one thing that struck me was the fact that no major new announcements were made for ASP.NET. Clearly, this is the sign of a mature technology but at the same time, Microsoft is putting a lot of resources and efforts in building a new platform in Silverlight. Does that mean that you should drop ASP.NET? Of course not: it’s mature, it’s stable, hundreds of 3rd party controls are available, it’s proven and you can find thousands of developers familiar with that technology. Why would you stop using it all of a sudden? But why is Microsoft working so hard on Silverlight? Because Silverlight fills the RIA gap in the Microsoft offer because developing complex RIA apps with AJAX is way too costly right now. So why is Microsoft working on the MVC Framework, a direct competitor to ASP.NET? Again, another model to solve different problems. It’s easier to use if you’re deep into TDD, it’s somewhat lighter but at the same time, it’s somewhat a return to Classic ASP. Well, it’s another tool in your .NET toolbox and this creates confusion for people who think in the “one size fits all / one ring to rule them all” way. Again, look at your project/assignment, analyse the problem/need and select the right technology to do the job. But in the long time, could Silverlight be so successful that it would replace ASP.NET? Maybe or maybe not. It certainly has the potential to do so but who knows at this point in time!

2009 prediction: ASP.NET will dominate and we will see a slow but steady Silverlight adoption. The MVC Framework will remain a niche tool for Agilists for now (and I’m not saying this in a pejorative way).

BizTalk vs Dublin
The .NET Framework 4.0 will include a set of extensions to Windows Server that will add new services to Microsoft’s app server. Features that will simplify the deployment, configuration, management, and scalability of WCF and WF applications. Basically, some of the same features found in BizTalk Server. So why would I bother with BizTalk and spend big money when I can get the same services for free? Well, BizTalk is an integration server and Dublin is a set of management tools extending Microsoft app server. Dublin will allow you to deploy more easily your WCF apps so instead of writing a Windows service to host your WCF services, the app server will be able to host them directly.
So you think you can write a BizTalk clone? Remember how BizTalk 1 was a piece of ****? And remember BizTalk 2? Microsoft only got it right with version 3 so yes, you can write a BizTalk clone using Dublin but it will cost you a lot more than purchasing BizTalk because Dublin and BizTalk are two different animals.

2009 prediction: Dublin will be widely used right away to help host WCF apps. BizTalk will not die and some people will get burned by trying to replace BizTalk with Dublin in a scenario where the use of BizTalk would have make more sense. FUD will run loose on the Web.

LINK 2 SQL vs Entity Framework
So Microsoft created some confusion by releasing two similar ORM technologies? Yes of course but if you look closely, they are somewhat similar and different at the same time. LINQ 2 SQL is RAD against SQL Server and the Entity Framework is the full blown ORM thing. Both use LINQ as the query language so if you invested in LINQ 2 SQL, your investment is not wasted and for God’s sake, LINQ 2 SQL is in the Framework; it cannot die!
One suggestion that I saw on the Web was to release LINQ 2 SQL on CodePlex so that people can update it since Microsoft has “abandoned” it. First, Microsoft never said that it has abandoned it. They will keep it as it is right now and they will put all their efforts on the Entity Framework. My hope is that when we’ll see new SQL Server releases, Microsoft will update LINQ 2 SQL to match some of the new features. So back to the CodePlex idea: I think it’s a bad one because people will try to match the features of the Entity Framework or Nhibernate and that will create more confusion because we will have similar products competing against each other.

LINQ 2 SQL = simple 1 to 1 mapping against SQL Server
Entity Framework = complex mapping against SQL Server and more

2009 prediction: people will still be confused and FUD will run loose on the Web

C# and VB vs Oslo
Microsoft have finally abandoned the traditional design surface where we connect little boxes as the way to model apps and I think that Oslo and M are very good concepts. Is this the modeling Holy Grail? I have no idea but it looks good. Can Oslo and M replace VB and C#? Of course not!
Every time that Microsoft launched a new way to model apps, these technologies never lasted more than one version. I would tend to have a wait and see approach. Take a look, experiment and wait for version 2.

2009 prediction: Olso and M will be curiosities. Let’s hope that they will not die as the other Microsoft modelling oddities.

Azure vs apps hosted in the enterprise
Microsoft has taken a bold approach to cloud computing. Instead of hosting your virtual machines running your apps, they will host your apps in a new cloud OS running in their virtual machines. But why would you do that? To drive IT costs down of course. Look, there’s something called a recession going on right now and it’s a nasty one. At some point, your boss will be asked by his/her boss to cut expenses drastically and maybe one way to do it is to go the cloud way. We’ll see but there’s one thing that I’m sure: this will be another tool in your .NET arsenal and it will not make sense to write all apps to run in the cloud. Again, look at your project/assignment, analyse the problem/need and select the right technology to do the job. I’m sure that people will get burned by using the cloud model on projects where it doesn’t make sense.

2009 prediction: Microsoft has a lot of work to do to convince people to move to cloud computing.

Jan 04

This one I found today, it was published on 18th of Dec by Tony Davis on http://www.simple-talk.com. Its quite interesting post I loved reading it.
Here is a short brief:
Visual Basic v9 appeared on November 19. In the past, the new release of Microsoft’s longest-running language might have caused a stir, but it was part of Microsoft .NET Framework 3.5 and there were plenty of other distractions. The changes to VB itself were pretty minor: The ‘Inline IF’ was finally retired in favour of a true ternary IF. We got support for LINQ, Lambda expressions like those of Python, support for XML Literals, and Type Inference. Hopefully, the real changes to the language will come with Visual Basic v10, which will use the Dynamic Language Runtime, and benefit from experience gained in the development of IronPython. It is set to be released with Silverlight 2 as ‘Dynamic Visual Basic’. In the meantime C# continues to increase its dominance in the .NET world. Poor JScript.NET seems to be in terminal decline despite its high quality, though it is, like VB, promised a DLR makeover for SilverLight, and is likely to be renamed ‘Managed JScript’.

For .NET scripting, things already look a lot livelier, thanks in part to the Dynamic Language Runtime (DLR). IronPython and PowerShell have, in the past year, found good solid niches, thanks to their effortless access to the CLR and, in the case of IronPython, excellent tutorials and good compatibility with existing Python code. We all hoped for more with IronRuby, which now seems to be stuck in a pre-alpha limbo due more to legal than technical problems. This is disappointing for those of us who liked some of the ideas in Ruby on Rails. While we wait for Ruby, there is Boo and Nemerle to play with.
read the whole

Dec 13

Part 4 from Bill Horst’s series, now its functions turn.

Functions

SQL SELECT clauses often involve functions, which can be scalar or aggregate. An aggregate function is applied to a field over all the selected records, while a scalar function is called with individual values, one record at a time. It is possible to re-create both kinds of functions with VB LINQ expressions, but in very different ways.

Scalar Functions

Scalar functions are called on each record with whatever parameters are specified. They can appear various places in a SQL query, such as in the SELECT clause. The Scalar Functions available differ from system to system, but usually, there will be an analogous VB method that can be used. If using a Scalar Function in a LINQ Select clause, you will probably need to specify an alias as well (FirstThreeLetters, CurrentTime).

SQL

SELECT LEFT(ItemName, 3) FirstThreeLetters, NOW() CurrentTime
FROM OrderTable

VB

From Shipment In OrderTable _
Select FirstThreeLetters = Left(Shipment.ItemName, 3), CurrentTime = Now

In the above case, Left and Now are methods already built into VB, defined in Microsoft.VisualBasic.dll. This will likely be the case for most common scalar functions you will find in SQL statements. Even if the function you wish to call does not exist in VB already, you can define your own methods, too. However, user-defined methods cannot be used in a Database query, as they will throw an exception at runtime. In the below example, MyFunction is a user-defined function called from the Select clause.

VB

From Shipment In OrderTable _
Select MyFunction(Shipment.Cost, Shipment.ShippingZip)

Aggregate Functions

Aggregate functions are called on certain fields over an entire set of records, and return one value. In a SQL statement, they can appear in the SELECT clause. With VB LINQ, this concept appears a bit differently.

A VB LINQ expression usually begins with a From clause. However, they can also begin with an Aggregate clause. The Aggregate clause has the same syntax as a From clause, except that it starts with a different keyword. If a query starts with an Aggregate clause, it must end with an Into clause. An Into clause is a comma-delimited list of Aggregate function calls, with aliases that can accompany them. The below example shows a SQL SELECT statement that uses Aggregate functions, and an equivalent VB LINQ expression.

SQL

SELECT SUM(Cost) TotalCost, COUNT(*)
FROM OrderTable
WHERE OrderDate > “Sept-29-2007

VB

Aggregate Shipment In OrderTable _
Where Shipment.OrderDate > #9/29/2007# _
Into TotalCost = Sum(Shipment.Cost), Count()

read source

Dec 10

This article comes from Scott Mitchell at 4guysfromrolla.com. Its good post which I liked and wanna share with you:

Extension methods allow a developer to tack on her own methods to an existing class in the .NET Framework. For example, imagine that our developer created a method named StripHtml, that strips HTML elements from a string using a regular expression. By associating this method with the System.String class, it could be called as if it was one of the System.String class’s built-in methods:

Dim str As String = "<b>Hello, world!</b>"
Dim strippedString = str.StripHtml()

Creating the Extension Methods with Visual Basic
In order to create the extension methods in Visual Basic we need to first create a Module. For each extension method you want to create, add a method whose first input parameter is of the type that you want to add the extension method to. Moreover, prefix the method with the Extension() attribute.

The following Module named DateTimeHelpers contains two methods: ToRelativeToCurrentTimeString(DateTime) and ToRelativeToCurrentUtcTimeString(DateTime), both of which accept a DateTime instance as their first input parameter. The methods are also marked with the Extension() attribute (which is found in the System.Runtime.CompilerServices namespace). The two methods call the private ToRelativeString method, which returns the appropriate string message based on the difference in time between the two passed-in DateTime values.

Imports System.Runtime.CompilerServices
Imports Microsoft.VisualBasic
 
Namespace Helpers
    Public Module DateTimeHelpers
       <Extension()> _
       Public Function ToRelativeToCurrentTimeString(ByVal dt As DateTime) As String
            Return ToRelativeString(dt, DateTime.Now)
       End Function
 
       <Extension()> _
       Public Function ToRelativeToCurrentUtcTimeString(ByVal dt As DateTime) As String
            Return ToRelativeString(dt, DateTime.UtcNow)
       End Function
 
       Private Function ToRelativeString(ByVal timeInPast As DateTime, ByVal currentTime As DateTime) As String
            If timeInPast.Date <> currentTime.Date Then
                ' timeInPast happend more than a day ago... show the date & time
                Return timeInPast.ToString()
            Else
                ' timeInPast and currentTime happened on the same day...
                Dim secondsApart As Integer = Convert.ToInt32(currentTime.Subtract(timeInPast).TotalSeconds)
 
                ' See if the date dt is within the last hour...
                If secondsApart < 10 Then
                   Return "Seconds ago..."
                ElseIf secondsApart < 60 Then
                   Return "Less than a minute ago..."
                ElseIf secondsApart < 3600 Then
                   Return String.Format("{0:N0} minutes ago...", secondsApart / 60 + 1)
                End If
 
                ' Ok, the date is more than an hour old... show the time
                Return timeInPast.ToShortTimeString()
            End If
       End Function
    End Module
End Namespace

We can now call these extension methods from a DateTime instance. In order to use an extension method, we first need to add an Imports directive to the code file, importing the namespace where the extension methods reside (Helpers). Upon doing that, the extension method is visible in the IntelliSense drop-down list, as the following screen shot illustrates.

read source

Oct 24

Thats something really good! Now in the new Visual Studio 2008 you don’t have to use underscore when writing text on multiple lines. Here is an example how we used to write it:

Dim oldWay = "this is a string" & vbCrLf & _
               "with formatting" & vbCrLf & _
               "and stuff" & vbCrLf & _
               "look ma, underscores" & vbCrLf & _

Now we can do something like that:

Dim newWay = <string>
this is a string
with formatting
and stuff
look ma, no underscores!!!</string>

The text formatting is preserved as well. All you have to do is get the .Value of the XElement, which is the string literal. As you can see this is much cleaner than what we’re used to. And if you still like to see your string literals in the default reddish color, you can easily change the color settings for VB XML literals in Tools –> Options –> Environment –> Fonts and Colors, then select “VB XML Text” and set the custom color to RGB(163,21,21).

Even more, now we can embed expressions using the <%= syntax.

Dim simple = <string>
This is a simple text merge example:
Hello, <%= Environment.UserName %>
                     </string>

Here is Beth Massi’s post about these features! Thanks Beth!

Oct 19

This language specification corresponds to the version of Visual Basic that will ship in Visual Studio 2008. The spec covers the following major new features:

• Friend assemblies (InternalsVisibleTo)
• Relaxed delegates
• Local type inferencing
• Anonymous types
• Extension methods
• Nullable types
• Ternary operator
• Query expressions
• Object initializers
• Expression trees
• Lambda expressions
• Generic type inferencing
• Partial methods

The following features are not covered but should be shortly:

• XML Members
• XML Literals
• XML Namespaces

Although it will be updated again for the final release, the VB team wanted to get this out to the community now.
Here is the source
Here is the actual link for download

TopOfBlogs