Visual Studio And The .NET Framework archives - .NET Developments

.NET Developments:

Visual Studio and the .NET Framework

May 26 2009   3:44PM GMT

Our readership survey is in!



Posted by: Yuval Shavit
Visual Studio and the .NET Framework, .NET Programming Languages, ASP.NET, C#, VB.NET, Open source, VS 2005 and .NET 2.0, VS 2008 and .NET 3.5

The vast majority of SearchWinDevelopment.com readers are using modern tools, but a significant number of them are also interested in maintaining legacy applications, according to a readership survey conducted by the site.

A preliminary look at the survey reveals that 87% are using Visual Studio 2008 or 2005. About 65% of respondents use one of those versions as their primary IDE.

.NET languages are very popular; legacy code also important

Three quarters of all respondents reported using one of the two main .NET languages, C# and VB.NET; for half of respondents, one of those languages is what they do most of their coding in. C# is the more popular language by a significant (but not overwhelming) margin of 48% to 38%. Legacy code is still important, though. One fifth of readers use C++ and almost a third use VB6 or earlier, although only 15% of all respondents use those older languages as their main programming language.

Interestingly, the “use at all” to “use as primary” stats aren’t symmetric within .NET. As I noted above, 48% of readers use C# and 38% use VB.NET. But while 36% of readers use C# as their primary coding language, only 17% use VB.NET as their primary. That means that 75% of respondents who use C# do so for most of their programming (36 / 48 = .75), but only 45% of VB.NET coders use that language as their primary.

Web development is huge, but not quite cutting edge

Unsurprisingly, Web development is very popular. Just over half of all SearchWinDevelopment.com readers work with ASP.NET. For most of those, Web development is their main responsibility. But despite the Web 2.0 craze, Silverlight isn’t nearly as popular.

Ajax development is strong, but relatively diverse. That is probably due in part to Microsoft changing strategies: although it has its own Ajax framework, the company recently decided to officially back the popular library jQuery and incorporate it into IntelliSense. About 30% of ASP.NET developers use ASP.NET AJAX, 23% use jQuery and 15% use another framework.

What you’re doing, and how you’re doing it

In case you’re wondering how other Windows developers get things done, the top four most popular programming methodologies are waterfall, extreme programming (XP), Agile and Scrum. But about a quarter of you aren’t employing any methodology at all! That could be because almost a third of respondents work in an environment with fewer than five programmers, but it’s still a bit surprising.

And as for what you’re doing, the majority of our survey respondents said that improving performance one of their architectural challenges. That’s to be expected, but what stands out is that that’s the only architectural challenge that a majority of our readers are facing. Almost 60% of our readers listed performance as a challenge their company is facing; the next popular choice, implementing a workflow, weighed in at about 42%.

Those are topics we haven’t covered extremely closely, so that feedback is great to have.

Lastly, it’s clear that many of you are interested in learning new tools and technologies. We asked readers to rank their interest in nine topics, including software-as-a-service and open source software, which Microsoft is warming up to. Most of the topics trended toward “highly interested,” with only scripting languages and grid computing technology trending toward disinterest. That might not bode well for Microsoft’s latest push to promote PHP on Azure.

Look for a more in-depth analysis of the survey in the coming weeks. In the meanwhile, to all of our readers who took the survey, our deep thanks!

Feb 20 2009   8:21PM GMT

MonoDevelop beta ups the ante for .NET development on Linux



Posted by: Yuval Shavit
.NET Programming Languages, Visual Studio and the .NET Framework

It’s been a busy couple of weeks for Mono, the Novell-backed project that’s developing a port of .NET for Linux/Unix OSs. Last week saw the release of Moonlight 1.0, a Linux port of Silverlight 1.0 that has passed all of Microsoft’s regression tests. This week, the group released the first beta of MonoDevelop 2.0, its C# IDE for Linux.

For all its recent talk about interoperability, Microsoft has focused fairly exclusively on Windows as it’s built out its development platforms. Visual Studio is a Windows-only product, despite rumors to the contrary, as is Silverlight. (We should note that Microsoft has helped the Mono group, both with the development of Moonlight and with Mono, the open source implementation of the .NET runtime.)

Of course, interoperability isn’t easy or clean. As I noted on the blog for our sister site SearchSOA, even the communications protocols can raise challenges as you start talking between Linux and Windows computers.

But a truly interoperable world, where Linux and Windows servers work side by side harmoniously and cohesively, won’t be possible until programmers can unify their development efforts across platforms. That’s where MonoDevelop fits in.

The new beta introduces some much-needed basics, like a built-in debugger, but it’s also improving its ASP.NET support. The IDE is also more compatible with Visual Studio; for instance, it now uses msbuild-style project files.

Projects like MonoDevelop will be crucial if companies want to really mix and match Linux with Windows, but that’s a big “if.” For now, as far as I know, the vast majority of .NET development isn’t on Linux, and the vast majority of Linux development doesn’t use .NET. As laudable as Mono’s goals are in trying to tear down that wall, I have to wonder how much demand there is for that level of interop in the mainstream.


Sep 2 2008   5:14PM GMT

Iterators, Lambda, and LINQ… Oh My!



Posted by: Contributing Bloggers
VS 2008 and .NET 3.5, C#

Since the creation of the .Net Framework, Microsoft has kept the concept of “Type Safe” at the forefront of their design goals.  When 1.1 shipped, the framework had a “generic” collection type called an ArrayList that seemed to break this goal.  Microsoft quickly went above and beyond with the 2.0 framework by adding Generics and Anonymous Methods to the mix.  Anonymous methods coupled with Generics paved the way to Lambda expressions, Extension methods,  and LINQ (Language INtegrated Query).  The topic of this paper is loosely defined as:  The path to understanding Lambda and LINQ.

What came first?

Iterating through a collection with a for-each construct has been around for a long time.  .Net has the capability and in the beginning it was the recommended way of looping through a collections of widgets to find something or count something.  The basic construct is:

        private int CountForEach()
        {
            int count = 0;
            foreach (DLDog Dog in Dogs)
            {
                if (Dog.FoodBrand == “Purina” )
                {
                    count++;
                }
            }
            return count;
        }

Nothing too earth shattering about this.  Assuming we have a collection of 10 dogs and 3 of them use “Purina”, we will return a count of 3.

How would Generics and Anonymous methods change this syntax?  In the .Net 2.0 framework we can simplify the previous code a little as follows:

        private int CountGenericDelegate()
        {
            MyActionCount = 0;
            Dogs.ForEach(MyAction);
            return MyActionCount;
        }

This is a little misleading because we still need to write the delegate method “MyAction” but it does give us some flexibility in that we can pass any method to the ForEach generic method that adheres to the Action<T> prototype which is a predefined delegate in .Net 2.0.  Here is what the MyAction needs to look like in this example:

        private void MyAction(DLDog Dog)
        {
            if (Dog.FoodBrand == “Purina” )
            {
                MyActionCount++;
            }
        }

Another predefined delegate is the Predicate<T> delegate.  This one returns a Boolean based on some condition.  The <T> is typically your List<T> type.  Here is an example that uses the Predicate<T>:

        private List<DLDog> QueryDelegate()
        {
            return Dogs.FindAll(ByTypeAndCost);
        }
        // Predicate<T> typed method for FindAll
        bool ByTypeAndCost(DLDog Dog)
        {
            if (Dog.DogType == “German Sheperd” && Dog.AnnualVet > 1500M)
                return true;
            else
                return false;
        }

Enter .NET 3.5 - SWEEEET!

In .NET 3.5 Microsoft pulled all punches and really exploited the power of delegates, generics, and anonymous methods.  Building on that technology they added extension methods, lambda, and LINQ to the system.  Now our first count example can be simplified as:

        private int CountLambda()
        {
            MyActionCount = 0;
            return Dogs.Count(n => n.FoodBrand == “Purina” );
        }

This syntax is foreign as you can see but after a short explanation it will become very natural.  The “=>” operator is loosely defined as “Goes To”.  Under the covers - the compiler is doing this:

        private int CountLambda()
        {
            this.MyActionCount = 0;
            return this.Dogs.Count<DLDog>(delegate(DLDog n)
            {
                return (n.FoodBrand == “Purina” );
            });
        }

Previous code sample courtesy of “Reflector“…

Lambda is nothing more than syntactic sugar for inline anonymous methods and the .Count method on a generic list is nothing more than an extension method provided by the .Net 3.5 framework to the .Net 2.0’s generic list class.  No smoke and mirrors here!

Now LINQ is another animal but simply exploits everything up to this point and the previous example looks like:

        private int CountLinq()
        {
            var query = from dog in Dogs select dog;
            return query.Count(n => n.FoodBrand == “Purina” );
        }

The query variable is of type IEnumerable<T> and the T in this case is a DLDog object.  The compiler ends up with the following:

        private int CountLinq()
        {
            return this.Dogs.Select<DLDog, DLDog>(
                delegate(DLDog dog)
                {
                    return dog;
                }).Count<DLDog>(
                delegate(DLDog n)
                {
                    return (n.FoodBrand == “Purina” );
                }
                );
        }

Notice the use of the .Select extension method.  The method is defined as:

      public static IEnumerable<TResult> Select<TSource, TResult>(
            this IEnumerable<TSource> source,
            Func<TSource, TResult> selector)

(In the Visual Studio help system… )

So in summary - LINQ is really syntactic sugar for the extension methods provided by the .NET 3.5 framework!  Simple! 
…and SWEEEET!

Send me an email if you want a copy of the source code used for this article.


Aug 13 2008   1:56PM GMT

SP1 for .NET Framework 3.5 and VS 2008 boasts faster install, reduced coding



Posted by: Jack Vaughan
Visual Studio and the .NET Framework

By Andrew Horne

The first service pack upgrades for .NET Framework 3.5 and Visual Studio 2008 feature faster application runtimes and a general upgrade to existing tools. The main new inclusion is a .NET Framework Client Profile, which allows for faster installations on client machines.

The .NET Framework service pack focuses primarily on speed, thanks to a sleeker download. This approach benefits both developers and end-users with faster installation times and runtimes. Among the new features are support for ASP.NET Dynamic Data and support for SQL Server 2008, opening up a new range of options for website development. Other aspects of the service pack include ADO.NET Data Services and ADO.NET Entity Framework, intended to allow greater database abstraction.

The Visual Studio service pack features upgrades to existing tools as well as the ability to work in SQL Server 2008. Upgrades are aimed at a less involved building process for both WPF and Ajax applications, while retooled features enliven both ADO.NET Entity Framework and JavaScript development.

Check out George Lawton’s article on the service pack upgrade for more information, plus commentary on the strengths of Entity Framework as opposed to those of NHibernate and other frameworks.


May 14 2008   2:32PM GMT

NET 3.5 SP1 and VS 2008 SP1 beta appears



Posted by: Jack Vaughan
VS 2008 and .NET 3.5, Database development and architecture

Microsoft released a beta of .NET 3.5 SP1 and VS 2008 SP1 releases. While devoted in great part to bug fixes, they also include new features, some that have been eagerly awaited. Versions of ADO.NET Entity Framework and the ADO.NET Data Services framework (Astoria) are included. Continued »


Mar 24 2008   10:49AM GMT

Anonymous Methods - Elegance or Kludge



Posted by: Contributing Bloggers
General Microsoft news, VS 2005 and .NET 2.0, C#

According to Wikipedia, a kludge (or, alternatively, kluge) is a clumsy or inelegant solution to a problem or difficulty. In engineering, a kludge is a workaround, typically using unrelated parts cobbled together. Especially in computer programs, a kludge is often used to fix an unanticipated problem in an earlier kludge; this is essentially a kind of cruft.

When I first stumbled upon the concept of anonymous methods in C# 2.0 the first thing I thought of was …jeez it’s just another name for GOTO!  I’ve since changed my mind.  Have any of you ever used the Gosub…  Return programming construct from way back in the GW-Basic days?  I’m dating myself but in a former life I had the responsibility of maintaining a servo controller program that ran a servo motor (a DC motor that is capable of moving in programmed increments forward and backward) for a plant that made flour tortillas.  (yes - for Taco Bell no less!)  But I digress.  This particular brand of “Servo Basic” as it was called did not have the ability to address function calls.  It was all done with line numbers.  The program started at 10 and ended at the highest line number.  The only way to program a function in this version of basic was to use the Gosub… Return construct.  For instance “Gosub 100″ would jump to line 100 in the program and start executing code until a “Return” statement was hit then control would return to the line after the calling “Gosub” statement.  It was all very archaic but very versatile when it was all you had. 

Now I tell you that story so I can tell you this one:  I was happily coding one fine day when I encountered a problem that I needed to solve and it occurred to me that a Gosub… Return would be perfect here!  It was a function with lots of values passed in that needed to perform the same processing multiple times but I didn’t want to pass all that data around on the stack.  This, my friends, is the perfect case for an anonymous method.  You can define an anonymous method anywhere inside a function and when you call the method, it has the same scope as the code that defined the method.  The example here uses a SqlDataReader to populate an object.  The reader may or may not have some columns in it.  Since the only way to determine the columns in the reader is to use the GetSchemaTable() function and look at the results, I wrote an anonymous method to perform the search and was able to use the search to check for the existence of the questionable columns. 

Notice the placement of the definition within the function.  It is defined after the definition of the ReaderSchema DataTable.  The executing code in the function has scope at the point of definition and so it “knows” about the DataTable.  The syntax is a little funny but makes sense once you work through it.  The name of the anonymous method is “HasColumn” and can now be called from anywhere in the function after its definition.  It returns a boolean and accepts a string as designated by the delegate it is based upon.

Now I could have simply put the HasColum() in its own function and passed the table in to it along with the column name I’m searching for but then I wouldn’t have this totally cool use of an anonymous method, now would I?  However, the question remains:  elegance or kludge?


Mar 17 2008   11:00AM GMT

LINQ, WPF supported in Visual Studio 2008



Posted by: Jack Vaughan
Ajax, VS 2008 and .NET 3.5, Windows Presentation Foundation

Now that VS 2008 is out of the box, so to speak, it appears that a new era in Windows development is upon us. Language-Integrated Query is one of several game-changing technologies now supported in the Microsoft software kit. Although it is still early and there is a lot of learning to do, LINQ is poised as a whole new way of developing with data.

It is fair to say that the first rush of .NET technology was about catching up with Java, although there was much unique about .NET too. With LINQ, for now, it seems Microsoft has stolen a march on the Java opposition.

I spoke recently with Jason Beres, director of product management at Infragistics, which is one of the major third-parties in the Microsoft market. Beres said people will take LINQ very seriously. “I think it going to be the de facto way to do any real data binding or object access moving forward,” he said.

With the new Microsoft tool kit comes Windows Presentation Foundation (WPF). Is WPF game changing? That is hard to say. When it was first conceived, the ubiquitous Web interface seemed to be overstressed, and ready to be replaced by a new generation of WPF-based Smart Clients that would use something like WPF. But, before WPF made it too market, AJAX came on strong as a means to give new life to Web interfaces.

This means the plate of companies like Infragistics is pretty full. Infragistics has just rolled out NetAdvantage for WPF 2007, which is compatible with Visual Studio 2008. At the same time, according to Beres, the company has been re-tooling its frameworks around ASP.NET AJAX as well.

For Infragistics and others, Silverlight looms as another alternative interface. Watch for Infragistics and others to provide Silverlight components, especially now that Silverlight 2.0 (which, more than its predecessor, rightly bears the mantle of “WPF/Everywhere”) arrives in its first beta form.

LINQ, WPF and VS 2008 have been primary areas-of-interest for the SearchWindowsDevelopment.com site for some time. We invite you to check out our LINQ VS 2008 pages, and to stay tuned.

RELATED INFORMATION:
> VS 2008 and LINQ Topic Page
> Introducing WPF
> Introduction to Silverlight 1.0


Mar 12 2008   2:26PM GMT

AJAX Enabled Web sites in Visual Studio 2008



Posted by: Contributing Bloggers
Ajax, VS 2008 and .NET 3.5

Visual Studio 2005 provides an Web site application template to create AJAX enabled ASP.NET Web sites.

However, when you use Visual Studio 2008, you will not find this template in the New Web site creation templates.  The reason for this is that  Visual Studio 2008, by default creates a .NET Framework 3.5 application.  See the .NET Framework type at the top right section of the window image below.

AJAX is now integrated into the framework.  In Visual Studio 2008 all web sites that are created using .NET Framework 3.5 are AJAX enabled.  You don’t have to create a separate AJAX enabled web pages.


Mar 11 2008   10:52AM GMT

Bill Gates has been popping up a lot lately



Posted by: Jack Vaughan
General Microsoft news, VS 2008 and .NET 3.5, .NET programming downloads

Bill Gates has been popping up a lot lately - at the Office Developer Conference, at the SharePoint Conference, and so on. An interesting leg on his journey - this is, after all, a farewell tour - was his stop at Stanford University on Feb 19.

The Stanford visit is one of many he’s made in recent years to drum up added interest in computer science among students. 

Programming seems less and less to be a career of choice, and this worries Gates. So he goes to colleges and addresses the students frankly about why he loves software.

It is not all together unlike his speeches to certified geeks. There is plenty of ‘neat’ stuff, ‘really cool’ stuff, and the funny video. But I’d recommend the Stanford transcript as a good entry point to a view on the state of computing today and over time.

Gates glosses over a few facts - there were, for example, software businesses before Microsoft. But he is right in saying his company was the major one to take the low cost-high volume approach to business software.

He discussed a dream ”required some heroic assumptions. ”

We had to believe that the cost of the hardware would come down. We had to believe that the volume would go up. And only then would the economics of being able to spend tens of millions of dollars to write a software package, and yet being able to sell it for say $100 or less, actually make sense.

Much software today is free. Microsoft does not mind that, if it is free too students who will go on to do way cool things, including perhaps becoming a Windows developer some day. At the same time Gates spoke at Stanford, the company announced its DreamSparks free software program, which Ed Tittel recently wrote about in ”Microsoft sparks creativity with DreamSpark student developer program” on SearchWinDevelopment.com.


Mar 7 2008   3:00PM GMT

Using Master Pages in Visual Studio 2008



Posted by: Contributing Bloggers
General Microsoft news, VS 2008 and .NET 3.5, WinForms, ASP.NET

The way you use Master pages has changed in Visual Studio 2008.  Remember, how in Visual Studio 2005 when you add a new Web Form in ASP.NET applications - you get to choose a master page to apply to the Web form.  If you choose to use a Master page - then the page that is added, when you check the HTML code for that page - it is stripped of all the standard HTML tags - only the Page directive and the <asp:Content> tags are available.  This is a Content page.

In Visual Studio there are two types of Web Forms available - Web Form and the Web Content Form

The Web Form is a standard Web Form - without the Master page, with its HTML code like a standard HTML page.  Whereas, the Web Content Form is the one to which you can attach a Master page.

The Web Form page also has a MasterPageFile property.  But, if you create a Web Form and then set the MasterPageFile property to link to your Master page you will get a run time error.

Content controls have to be top-level controls in a content page or a nested master page that references a master page.

This is because content pages must not have another other HTML tags or controls. 

If you want to use Master Pages use Web Content Form, otherwise use the Web Form.

Another nice feature in Visual Studio 2008 - is that in that in the top right corner of the Design window of the Web content page is a link to the Master page that this page is linked to.  Also, the “Split” view is cool.. you can now see the source and the design view tiled in the design area.