.NET Developments

March 11, 2008  10:52 AM

Bill Gates has been popping up a lot lately

Yuval Shavit Profile: YuvalShavit

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.

March 7, 2008  3:00 PM

Using Master Pages in Visual Studio 2008

Brein Matturro Profile: Brein Matturro

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.

March 3, 2008  3:40 PM

Report from the field: Visual Studio 2008

Yuval Shavit Profile: YuvalShavit

NOTABLE THIS WEEK – There is little question that tools these days are subject to rolling releases. Noris there much question that bosses still look for reasons to put off new migrations. Developers want to get their hands on the newest stuff so they are ready when the tools and runtimes are truly released. Managers are not always wrong in waiting until the software is more fully baked.

Well, Visual Studio 2008 went to its final debutante ball last week. The event was held in Los Angeles, and it was entitled ”Heroes Happen Here.” As Microsoft hoped, VS 2008 was rolled out along with Windows Server 2008 and SQL Server 2008 (which, admittedly, is still something of a ‘player to be named later,’ as all of its parts did not get into the box on time for the Heroes launch.)

”With the launch of Visual Studio 2008,”  CEO Steve Ballmer told the Heroes crowd, ”you’ll see performance again ramp up dramatically as we improve compiler speeds and developer productivity really quite dramatically. Start times, load times, compile times are all quite dramatically improved with this launch of Visual Studio 2008.”

After a long journey the tool once code-named Orca is out as Visual Studio 2008. For some of us, the move from code name to product name is anti-climactic. For many more of us, the real game is just about to begin.

To get a gauge of where things are headed, correspondent Coleen Frye spoke to Visual Studio 2008 users, and her work is on display on SearchWinDevelopment.com. In ”A view on VS 2008, ” a development manager at a cutting-edge Internet agency tells Frye that improvements to Team Foundation Server are among the keys that led the firm to take the VS2008 plunge. So, Ballmer’s boast of load and compile time improvements may be sound.

SearchWinDevelopment.com has been following Orca elements for a while. A clear area of interest has been LINQ, which spans both VB and C#. Check out the LINQ Learning Guide to get up to speed on this new way of working with data programmatically.

A slew of Visual Studio 2008 tips and tutorials is available as well in the site’s Visual Studio 2008 Learning Guide.

February 28, 2008  4:48 PM

VB6 Programmers – What happened to Printer.Print?

Brein Matturro Profile: Brein Matturro

This post goes out to all you VB geeks that are wondering what happened to Printer.Print in VB.  This may be a dated topic but I have a feeling there are a few out there longing for those VB6 days when the printer was always sitting there loyal and waiting.  The VB6 programmer’s best friend.  Well, when you needed to print something anyway.   Once upon a time you could just write a few lines of code and *poof* you created a page of information for your users.  Now you have this PrintDocument thing and PrintDialogs and PrintPreviewDialogs and Graphics objects and the list just goes on and on.

Let me re-introduce you to printing in .NET.  Once you get through the slight grade of the learning curve, you’ll be convinced that .Net printing is better than anything you did with the printer object in VB6.

The task – print a smiley face on a piece of paper.  Lines of code in VB6 – about 6.  Lines of code the .net way – about 22 (but you could consolidate…).

That doesn’t sound like a good trade off.  It seems its easier in VB6.  However – what if you wanted to create a bitmap of the smiley face and then use that bitmap in various places as well as print it here and there?  How many line of code do you need now?

 In VB6 – I have no idea.  You would need to drop down to the API level and call graphics functions against a Device Independent Bitmap device context making sure you clean up after yourself in those places where cleanup is necessary.  Then you would need to save that bitmap to a file and/or have an image control somewhere that you could set using the memory bitmap (again using API calls).  Then perhaps you could print the smiley here and there using some similar printing code.

In .NET – its the same 22 lines of code and you can run those lines of code against any “Device Context” (using API terminology) by simply passing a Graphics object to the code that actually creates the smiley.  You could even create a bitmap object and simply use that bitmap throughout your program without ever getting close to the windows API.
Here are my CreateSmiley functions:

private void DrawSmiley(Graphics g, int Width)
  Pen p=new Pen(Color.Black);
  SolidBrush b = new SolidBrush(Color.Black);
  SolidBrush YellowBrush = new SolidBrush(Color.Yellow);
  Point Origin = new Point(0, 0);
  Size HeadSize=new Size(Width,Width);
  Rectangle Container=new Rectangle(Origin, HeadSize);
  Point LeftEye=Origin;
  Point RightEye=Origin;
  Point SmileTopLeft = Origin;
  LeftEye.Offset((int)(HeadSize.Width*.25), (int)(HeadSize.Width*.20));
  RightEye.Offset((int)(HeadSize.Width*.65), (int)(HeadSize.Width*.20));
  SmileTopLeft.Offset((int)(HeadSize.Width *.20), (int)(HeadSize.Width * .40));
  Size SmileSize = new Size((int)(HeadSize.Width*.60), (int)(HeadSize.Width*.40));
  Size EyeSize=new Size((int)(HeadSize.Width * .10),(int)(HeadSize.Width * .10));
  g.FillEllipse(YellowBrush, Container);
  g.DrawEllipse(p, Container);
  g.FillEllipse(b, new Rectangle(LeftEye, EyeSize));
  g.FillEllipse(b, new Rectangle(RightEye, EyeSize));
  g.DrawArc(p, new Rectangle(SmileTopLeft, SmileSize), 180, -180);

private Bitmap CreateSmiley(int Width)
  Bitmap Smiley = new Bitmap(Width, Width);
  Graphics g=Graphics.FromImage(Smiley);
  DrawSmiley(g, Smiley.Width);
  return Smiley;

Pretty basic stuff and different than you did in VB6. You have access to all the API stuff without dropping down the the API level. Now as far as printing goes – there are a few objects that need your attention. The PrintDocument, PrintDialog, and PrintPreviewDialog objects. The PrintDocument object is the container for all your drawing methods. It handles paging and rendering of the stuff you are printing. The PrintDialog and PrintPreviewDialog objects manage the actual device you are printing to. The PrintDialog as you may have guessed will print to a printer while the PrintPreviewDialog prints to a preview window.

Here is some code that uses a PrintPreviewDialog and calls the printing methods above:

private void button1_Click(object sender, EventArgs e)
  PrintDocument pdoc = new PrintDocument();
  // hook up the event handler for the printpage event
  pdoc.PrintPage += new PrintPageEventHandler(pdoc_PrintPage);
  PrintPreviewDialog pdialog = new PrintPreviewDialog();
  pdialog.Document = pdoc;
  pdialog.ClientSize = new Size(640, 480);
void pdoc_PrintPage(object sender, PrintPageEventArgs e)
  Bitmap smiley=CreateSmiley(300);
  e.Graphics.DrawImage(smiley, new Point(150, 150));
  e.HasMorePages = false;

The VB.Net code is virtually the same. Just change the declaration variables around, change the curly braces to Sub/End Sub, remove the semi-colons and your 80% done.
This method of printing is easy to hook up and offers a great deal of flexibility but if you want real reporting power – there is no substitute for a good reporting engine such as SQL Server Reporting Services or Business Objects’ Crystal Reports. There are others.  I’m a convert.  I was a Crystal Reports bigot but if you’re using a SQL Server database – you get reporting services for free and I must admit after running SQL RS through its paces – I like it better than Crystal Reports.  That, of course, is my opinion.


February 27, 2008  11:57 AM

Microsoft releases .NET Micro Framework Version 2.5 updates

Yuval Shavit Profile: YuvalShavit

Microsoft updated the .NET Micro Framework, releasing Version 2.5 with improvements in Web Services and TCP/IP support.

.NET Micro Framework Version 2.5 includes a Web Services on Devices implementation compatible with Windows Vista and supported by the other Microsoft Windows Embedded platforms.

With Web Services on Devices, Micro Framework devices can discover and communicate with other devices on a network without need for user configuration. While some observers initially scoffed at Web services as a ‘real-time’ embedded solution, a growing consensus hold that it is ‘real-time’ enough for a slew of solutions.
Also, with Version 2.5, the framework gains native TCP/IP stack support, and, let’s face it, TCP/IP is nothing short of the greatest protocol of all time.

Microsoft also said it has inked a deal with oft-time rival IBM to collaborate on a pre-installed Windows embedded-based point-of-service solution for the retail and hospitality industries.

February 26, 2008  9:02 AM

Every time a bell rings…

Brein Matturro Profile: Brein Matturro

If you have upgraded from Visual Studio 2003 to Visual Studio 2005, you have probably noticed one of the major annoyances: they took away the sounds.

With VS 2003, you could set things up so that your computer made a happy little sound at you when a build succeeds. This was great because I could turn away from the monitor for a moment, if only to rest my eyes, until the sound brought me back. Or I could check email, get another glass of cold caffeine, etc.

I’d even gone a step further by making my app play the sound of a bell ringing, when it had finished booting itself after a successful build in the dev environment. This extended the time I could gaze out my window at the tangle of weeds we call a lawn.

But in VS 2005, all you can do is hear a sound when you hit a breakpoint. Big deal. I want the cheerful news that everything is copasetic. So why did they take out the sounds? To save a few hundred milliseconds. That appears to be the official word.

And the official word, back in April 2006, was that they were working on fixing this “bug” for the next release. Well, the next release has come and gone. Still no sounds. In the meantime, they suggest, you can write an add-in.

In Service Pack 1, there is a new control called SoundPlayer, which appears to do the same thing a simple two-line function can do. Yes, without it you have to declare an API function, which means unmanaged code and wild-eyed people grabbing you by the collar to tell you what a mistake this is, but I’ve been using API calls very carefully since .NET appeared and have yet to suffer (I am knocking on my desk top with both fists). I guess it comes down to this: I’d rather have my sounds back than a relatively useless control.

I saved much more time when I had that happy sound than the hundreds of milliseconds they were worried about. At least my app still rings a bell when it’s up and running.

But they could have told me.

February 25, 2008  9:39 PM

Community Server steward Telligent rolls out Graffiti CMS engine

Yuval Shavit Profile: YuvalShavit

SearchWinDevelopment.com recently caught up with Rob Howard, who graced these pages in the Pre Silverlight Days. Howard rode the first blog wave at Microsoft, and has continued on the social networking trail as head of Telligent, provider of Community Server, a blogging application running on the ASP.NET platform.

Recently, Telligent has launched Graffiti, which takes a big conceptual step up the stream from blogging. Graffiti is a Content Management System [CMS], which is what people find they need when they bash about in the blogpond long enough.

Trouble with CMS is: There is a wide spectrum with not too many nodes along the way. You have the big vendors [Vignette, Interwoven] with rich products and pricey price tags on one spectra end .. and on the other end there is WordPress and Blogger with low cost and low features. Telligent sees opportunity.

Graffiti is a light weight CMS platform, Howard told us. It is a good fit in a more disparate environment, he indicated. He said many companies are beginning to field more than a single CMS type. They are supporting what he calls ‘niche focused publishing platforms.’

As with past Telligent efforts, Graffiti runs on ASP.NET. But this time, it also runs on Linux and Mac OS, and Mono. It supports various DBs, including MySQL.

Telligent has more in store. Besides upcoming new revs of Community Server, there is the Harvest Reporting suite due from the company. Said Howard, it rolls up 130 pre-built reports that let blogmeisters slice and dice their community data. Blogging may be a commodity item, yes. But the software the grows up around the blogging phenomenon  may be industries onto themselves. With its stabs at CMS and reporting, Telligent may point the way toward a trend.

February 22, 2008  9:47 AM

Power Tools for VSTO now available

Brian Eastwood Profile: Brian Eastwood

Microsoft has released a set of Power Tools for Visual Studio 2008 Tools for Office. It’s called v1.0.0.0 and it’s available at the Microsoft Download Center.

The download includes a set of reusable class libraries and a Ribbon IDs ToolWindow tool.

The following operating systems are supported:

  • Windows Server 2003
  • Windows Server 2008
  • Windows Vista
  • Windows XP

It is compatible with Microsoft Office 2007.

February 21, 2008  10:07 PM

Microsoft again vows to promote interoperability – shares new API info

Yuval Shavit Profile: YuvalShavit

Microsoft said Thursday it will provide extensive documentation for APIs covering its major software products, including Office 2007, the Windows client and server, and the .NET Framework. Much of this information had been closely held, available only along with trade secret licenses or only within the company.

The move is an apparent extension of concessions Microsoft made late last year in the face of a difficult European Union Commission antitrust case. As described by Microsoft Chief Software Architect Ray Ozzie at a press briefing, the API initiative is also a response to an industry-wide move toward software that is delivered as a Web service. Major Microsoft managers Steve Ballmer, Bob Muglia, and Brad Smith appeared at the briefing along with Ozzie.

Ozzie described the API move as a strategy shift. Software users need software and services that are “flexible enough such that any developer can use their open interfaces and data to effectively integrate applications or to compose entirely new solutions,” said Ozzie.

Microsoft’s Muglia said the company would publish the more than 30,000 pages of protocol documents created as a part of the effort to meet requirements set by the European Commission and the Department of Justice to divulge information to independent software and hardware vendors.

“In the coming months, and no later than the end of June, we will publish  the protocols in Office 2007 that are used to connect to any other  Microsoft product, including Exchange Server 2007 and SharePoint Server 2007, as well as — we will take the .NET Framework related protocols and  publish those on our Web site, on MSDN,” said Muglia.

For his part, Steve Ballmer said the company was designing new APIs for Word, Excel and PowerPoint that will allow developers to plug in additional document formats, and enable users to set those formats as their default for saving documents.

In the blogsphere, early reaction to the Microsoft announcement sometimes centered on its relation to the EC’s case against the company, and efforts by Microsoft to gain OSI acceptance for its OOXML format. In his Digital Daily Feed blog John Paczkowski notes that the European Commission seems unimpressed by Microsoft’s declaration of interoperability principles. The EC said in a statement: “This announcement does not relate to the question of whether or not Microsoft has been complying with EU antitrust rules in this area in the past.”

The intersection of patents and open software remain an issue for Microsoft to address. For its part, Linux vendor Red Hat wants more, saying that MS should make additional commitments. Editor Joseph Ottinger discusses this with the Java community at TheServerSide.com.

February 21, 2008  10:12 AM

Typed Datasets and the ConnectionString problem

Brein Matturro Profile: Brein Matturro

(Editor’s note: This is the first blog post by Kalyani Sundaresan, who will be writing on the .NET Developments blog from time to time. Sundaresan is a .NET developer and teacher who is starting to familiarize herself with Visual Studio 2008, particularly its unit testing capabilities. Welcome aboard, Kalyani!)

I use Datareaders, mostly, for my data needs in my .NET applications, but in a recent application development project I used Typed Datasets. Here are some of my thoughts on how it all went.

Typed Datasets are strongly typed data tables and TableAdapters. Datasets are the logical entities while TableAdapters perform the actual data access task by interfacing with the database.

There are some logistical and productivity advantages of using Typed Datasets:

  • You can keep your tables together and maintain them with your application solution.
  • You have less code to write to check datatypes, null values and so on. 

Keep it all together: After creating all the tables I needed for the application,  I made a comprehensive list of my data needs for the application. The bulk of these requirements — where you are populating a GUI list, for example, or simple data extraction — are just SELECT statements.  For all these needs, just create XSDs and drop the tables to the XSD in the designer and add your queries to the Table Adapters.  That simple.

Less coding: Being typed, there was less coding to be done for checking Datatypes for column data retrieval, data rows, null checking, assigning nulls, etc. That greatly enhanced coding and reducing the number of cycles during code testing.

Typed Datasets provide an advantage in maintaing code and makes code easier to develop.  That is the part I liked.  I did not have to always remember to type-check and was able to work within the IDE for all database coding. The maintenance advantage that I have obtained from this has been a real timesaver.  I did not have to track down changes — check out code from source control and you have all the changes.  Within the groups I have worked, database code source control has tended to be a weak spot.

For a new user of Typed Dataset — a small detail, if ignored, can cost you some time.

Now that I know it, it is a no brainer.

Say you are writing an ASP.NET application and your data access layer is built into a middle tier coded in a DLL file. You will find that you are dealing with two database connection strings — one in the Settings.Settings file in the DLL project and one in the Web.config file in your Web application project.  The key here is to give the two connection strings EXACTLY the same name.  For example, when you create a new data connection to your database, while creating your Table Adapters – the connection string is stored in the Settings.Settings file in the Settings section.  From the GeneratedClassNamespace attribute of the SettingsFile tag, get the name space.  Then, in the ConnectionStrings section of the web.config file set the connection string name to:


Here is an extract from the Settings.Settings file:


<?xml version='1.0' encoding='utf-8'?>  

<SettingsFile xmlns = "http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="DALLibrary.Properties" GeneratedClassName="Settings">  

  <Profiles />  


    <Setting Name="DATAConnectionString" Type="(Connection string)" Scope="Application">  

      <DesignTimeValue Profile="(Default)"><?xml version="1.0" encoding="utf-16"?>  

<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">  

  <ConnectionString>Data Source=databasename;User Id=dbUser;Password=db123!@#;Initial Catalog=dbtable;Trusted_Connection=False;</ConnectionString>  







Connection string in Web.config  


<add name="DALLibrary.Properties.Settings.DATAConnectionString" connectionString="Data Source=databasename;User Id=bUser;Password=b123!@#;Initial Catalog=dbtable;Trusted_Connection=False;" providerName="System.Data.SqlClient"/>  


Remember the performance penalties of using a Dataset. Even though the first point makes me feel good about using the Typed Dataset — it helps me maintain code through one IDE, remember — Datasets have performance issues that you must consider.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: