innoQ

Hartmut's BoxHartmut Wilms’s Weblog


.NET | Main

24.03.08

Installing Visual Studio 2008 on Windows Server 2008

Today I’ve had a hard time installing Visual Studio 2008 on Windows Server 2008. I finally wanted to test WCF hosting within WAS.

The installation broke several times with Error 1330:

"… d:\cab11.cab has an invalid digital signature …"

I tried copying the installation files to HDD, another installation media, mounting the ISO image - all to no avail.

Finally I found a blog post on the issue by Heath Stewart. Within the comments to his post he recommends to

check your performance settings, to see if the failed machines are set for Background Service Optimization? Also, are these Win2K3 machines or what platform are they?

On Vista: "Start"->Right click on Computer, select Properties. On the left, select "Advanced System Properties", click "Settings" under "Performance", then click the "Advanced" tab. Is "Programs" or "Background services" checked.

I switched the performance settings to "Programs" and also defragmented the target disk with the build-in defragmenter. Afterwards the installation ran perfectly fine.

Posted by Hartmut Wilms at 22:07 | Comments (1) | TrackBack

24.02.08

New LINQ to XSD release

It has been a long time since the last preview of LINQ to XSD, which targeted Beta1 of Visual Studio 2008. Now Microsoft’s XML team is announcing a new release that works with Visual Studio 2008 RTM.

If you’re a VB developer LINQ to XSD won’t mean anything to you. C# developers will now be able to work with LINQ to XML in a type-safe manner:

The LINQ to XSD preview illustrates our initial thinking on a strongly-typed programming experience over LINQ to XML. Instead of working with untyped XML trees, LINQ to XSD allows you to program in terms of strongly-typed classes, generated based on an XSD schema.

Although LINQ to XSD fits into MS’s strongly typed thinking, you’ll loose the benefits of untyped XML trees, such as a uniform interface for accessing XML.

Posted by Hartmut Wilms at 14:09

29.01.08

Visual Studio 2008 Tip: Resolving Namespaces and Removing Unused Using Statements

For quite some time I’ve been wondering why Visual Studio still doesn’t meet the minimal requirements of development productivity. Features such as resolving namespaces, finding classes and automatically resolving namespaces and navigating to the definition of a class by simply pressing STRG and clicking the left mouse button, which are offered by about every JAVA IDE, are missing. Instead Visual Studio 2008 presents #1001 of the most annoying wizards ever.

ReSharper comes to the rescue, but it doesn’t support C# 3.0, yet. David Hayden shows how to get along with Visual Studio 2008 regarding namespaces:

It turns out, Visual Studio 2008 actually has good support for resolving namespaces and optmizing using statements that can get you the functionality if you are not using ReSharper.

[…]

Pressing Ctrl + . will bring up a context-sensitive menu that allows you to add a using statement or optionally fully qualify the path to the class.

[…]

The other nice thing that ReSharper does is remove unused using statements using Ctrl+Alt+O.

We can get that using Visual Studio 2008, because you may have noticed the cool context-sensitive Organize Usings Option:

Visual Studio 2008 Organize Your Usings

[…]

I’ve quit hoping for something like “Call Hierarchy” within Visual Studio or at least ReSharper, but David’s tip saved me from uninstalling VS 2008.

Posted by Hartmut Wilms at 21:08 | Comments (1)

07.11.07

Visual Studio 2008 will be released at the end of this month

S. Somasegar, Vice President of the Developer Division at Microsoft, announced on his blog, that Visual Studio 2008 and the .NET Framework 3.5 will be released at the end of this month. The official marketing launch, which will include Windows Server 2008 and SQL Server 2008, is still scheduled for February 2008.

 

Great news. Get ready!

Posted by Hartmut Wilms at 10:59

02.11.07

WCF v2 Features in .NET Framework 3.5

Christian Weyer has published some entries about the new WCF features of .NET 3.5.

In his first post he give a rough overview of the popular and not so popular new features. One of these features is the new Web Programming Model. Although support for RESTful Services is an important feature for the next version of the .NET Framework, I’m wondering, whether a slick light-weight solution (such as Mindtouch Dream), which remains true to the principles and simplicity of REST, isn’t much better suited than an all-in-one silver-bucket attempt.

Dominick Baier joins in and writes about Usernames over Transport Authentication in WCF.

In his most recent blog post Christian publishes a list of all updated/new WS-* specs in WCF v2.

Posted by Hartmut Wilms at 12:13

23.10.07

Improved URL Mapping for Castle MonoRail

Hammett announced a new MonoRail Routing Engine on his blog. The Routing Engine is responsible for mapping URL patterns to Controller actions, which has been a weakness of MonoRail so far. As Hammett stated on his blog, the need for an improvement has mainly been triggered by the announcement (and features) of the ASP.NET MVC Framework.

The basic idea is to map (friendly) URLs to the actions of your controllers:

Suppose you want to offer listing of say, cars. You want that the urls show the data that is being queries on the resource identifier, not through the query string (have you read about REST?).

Something like:

www.cardealer.com/listings/ -> can list all or show a search page, up to you
www.cardealer.com/listings/new/ -> shows a nationwide list of new cars
www.cardealer.com/listings/old/ -> shows a nationwide list of second hand cars
www.cardealer.com/listings/new/ford -> new ford cars
www.cardealer.com/listings/new/toyota -> new toyota cars

In order to allow for friendly URLs you’ll have to remove all script mappings from your web site and route all requests to the ASP.NET ISAPI extension. Many people don’t like the idea, stating that “no one would do or want to do such a  thing”. What’s the problem with this approach? I’ve been developing web applications for several years (as part of enterprise applications) and I’ve never experienced the need to serve static content. What’s the use of databases then? However, if you want to serve static content as well, you might follow David Moore’s suggestion to “have the web site and a separate web site to handle static content (images/css/js)”.

The Routing Engine is configured in the Application Start event:

RoutingModuleEx.Engine.Add(
    PatternRule.Build(“bycondition”, “listings/<cond:new|old>”, typeof(SearchController), “View”));

This piece of code tells the engine to route URL-requests such as “/listings/new” or “listings/old” to the SearchController’s View action/method, which expects a parameter called “cond”. The parameter values might be “new” or “old”. The StandardUrlRules utility class allows to easily define generic patterns for all actions/methods of a controller.

The code is available from the MonoRail SVN repository.

Posted by Hartmut Wilms at 20:45 | Comments (2)

08.10.07

ASP.NET MVC Framework

[Update]: Scott Hanselman has posted the videos of the ASP.NET MVC Framework talks.

Scott Guthrie announces ASP.NET MVC Framework at ALT.NET conference. There have been rumors about an MVC Framework for ASP.NET in March 2007, already.   Jeffrey Palermo  wrote about a special meeting with Scott Guthrie on the MVP Summit. Now Scott officially announces the framework and claims that we might expect a first CTP within the next two months and a V1 in Spring 2008. Jeffrey has the details.

He names some of the goals:

Nima Dilmaghani provides further details on Scott’s talk and the integration points for existing ASP.NET technology and other frameworks such as Castle’s MonoRail and Windsor. Even Roy Osherove praises the new MVP Framework for ASP.NET:

My take away - finally they get it. I wish there were more guthries out there in the b0rg.

Regarding the impact on MonoRail Jeffrey says:

MonoRail is MVC.  This is MVC, so yes, it’s very similar but different.  This gives us a controller that executes before a view ever comes into play, and it simplifies ASPX as a view engine by getting rid of viewstate and server-side postbacks with the event lifecycle.  That’s about it.  MonoRail is much more.  MonoRail has tight integration with Windsor, ActiveRecord and several view engines.  MonoRail is more than just the MVC part.  I wouldn’t be surprised if MonoRail were refactored to take advantage of the ASP.NET MVC HttpHandler just as a means to reduce the codebase a bit.  I think it would be a very easy move, and it would probably encourage MonoRail adoption (even beyond its current popularity).

The Castle PMC has a similar take on the issue:

We also believe that MonoRail has been providing the same thing for the past two and half years, and will continue to do so. We’re grateful that MS has chosen to offer integration points for Monorail and the Castle stack and as soon as it’s available we will be working to integrate it with the rest of our projects.

Is MS’ MVC better? Worse? Only once we have used both will we be able to tell.

I would like to agree with Jeffrey that this might encourage MonoRail adoption. At least both frameworks would share some common concepts and the programming models won’t differ that much anymore. But common sense tells me that MSFT might try to do business as usual, i.e. make a (bad) copy of a good concept and get rid of the competing framework/tool along the way. I’ll have to put my faith in Scott ;-) (who’s proven to deserve as much several times).

Posted by Hartmut Wilms at 21:27

03.10.07

Microsoft Releases Source Code for the .NET Framework

Scott Guthrie announces today that Microsoft will offer “the ability for .NET developers to download and browse the source code of the .NET Framework libraries, and to easily enable debugging support in them” later this year.

According to Daniel Moth

The cool bit is not that you can just read the framework code in your favourite text editor once you download and accept the license; no, the real goodness is that when you debug your applications with Visual Studio 2008 you will have the option to debug right down into the Framework code (with an autodownload feature from an MSDN server)!

Scott Hanselman has a Podcast on the topic and Channel9 will be publishing a video at the end of the week.

Posted by Hartmut Wilms at 21:42

27.09.07

Duck Typing in C#

I stumbled upon David Meyer’s Duck Typing Project while searching for infos about the DLR:

The duck typing library is a .NET class library written in C# that enables duck typing. Duck typing is a principle of dynamic typing in which an object’s current set of methods and properties determines the valid semantics, rather than its inheritance from a particular class. (For a detailed explanation, see the Wikipedia article.)

Beyond simple duck typing, this library has evolved to include different forms of variance in class members and other advanced features.

Very cool: “Although there is a performance hit when a new proxy type is generated, use of the casted object is virtually as fast to call as the object itself. Reflection.Emit is used to emit IL that directly calls the original object.”

Posted by Hartmut Wilms at 20:13

Issue Dynamic LINQ Queries to SQL Databases with LINQPad

Can’t wait for C# 3.0 and LINQ? Well you don’t have to! Dynamically query SQL databases today in LINQ: no more struggling with antiquated SQL. Download LINQPad and kiss goodbye to SQL Management Studio: LINQPad supports LINQ to objects, LINQ to SQL and LINQ to XML—in fact, everything in C# 3.0 and .NET Framework 3.5. LINQPad is also a terrific learning tool for experimenting with this exciting new technology.

LINQPad

Joseph Albahari, co-author of C# 3.0 in a Nutshell, has published LINQPad (Beta) on his website. LINQPad requires .NET Framework 3.5 Beta 2 and allows to issue dynamic LINQ queries to SQL Server databases. It’s a great way to get acquainted with LINQ and to get to know its workings. Got, get it!

Posted by Hartmut Wilms at 19:26

24.09.07

Astoria Updated for Visual Studio Beta 2

Project Astoria has been updated to run with Visual Studio Beta 2. Nicholas Allen has the details.

Posted by Hartmut Wilms at 14:00

MSBuild vs. NAnt

Tomas Restrepo has posted a nice comparison of MSBuild and NAnt. Although I’ve been using MSBuild for a long time, I’m thinking of giving NAnt a try. MSBuild is missing some useful tasks, especially concerning deployment of web applications and configuring IIS. Community tasks are available, but they are very often lacking properties in order to customize the tasks to my requirements/likings:

My recent efforts of migrating a web application from WebForms to MonoRail might have influenced my decision to have a look at NAnt (Castle is build by an NAnt script).

Posted by Hartmut Wilms at 13:55

Castle RC3 has been released

It’s been a long time, but finally Castle Project Release Candidate 3 has been released. Hammett has published the list of changes and the current release can be downloaded here.

Castle is an open source project for .net that aspires to simplify the development of enterprise and web applications. Offering a set of tools (working together or independently) and integration with others open source projects, Castle helps you get more done with less code and in less time.

The main components of Castle are:

You might also download the current development bits from the Subversion Repository. An NAnt build scipt is included.

Posted by Hartmut Wilms at 13:40

10.09.07

Know your LINQ

Ian Griffith writes about the problems he ran into while using LINQ for real. In  LINQ to SQL, Aggregates, EntitySet, and Quantum Mechanics he starts with Aggregates and  null values:

The first issue is that an aggregate might return null. How would that happen? One way is if your query finds no rows. Here’s an example: […]

decimal maxPrice = ctx.Products. Where(product => product.Color == "Puce").
Max(product => product.ListPrice);

This code fragment will throw an InvalidOperationException due to the assignment of a null value to a decimal. The problem lies in the signature of the Max extension method, which return a TResult instead of a TResult? (nullable return type). This is by design, because TResult wouldn’t allow to use reference types in your lambdas. Ian provides a rather simple solution to the problem:

If we want Max to return us a nullable type, we need to make sure the selector we provide returns one. That’s fairly straightforward:

decimal? maxPrice = ctx.Products.
    Where(product => product.Color == "Puce").
    Max(product => (decimal?) product.ListPrice);

We’re forcing the lambda passed to Max to return a nullable decimal. This in turn causes Max to return a nullable decimal. So now, when this aggregate query evaluates to null, maxPrice gets set to null – no more error. 

The rest of his article discusses issues when combining queries in order to use aggregate functions across relationships. Be sure to read every line of the article, it’s worth your time. There’s no sense of summarizing his words, because the topic is a rather complex one. The one thing to point out is that using LINQ requires to know LINQ:

The critical point here is to know what LINQ is doing for you. The ability to follow relationships between tables using simple property syntax in C# can simplify some code considerably. With appropriately-formed queries, LINQ to SQL’s smart transformation from C# to SQL will generate efficient queries when you use these relationships. But if you’re not aware of what the LINQ operations you’re using do, it’s easy to cause big performance problems.

As always, a sound understanding of your tools is essential. 

There’s nothing left to say.

Posted by Hartmut Wilms at 17:40 | Comments (1)

27.07.07

Visual Studio 2008 Beta 2 is now available

Visual Studio 2008 Beta 2 is now available for download. Beta 2 includes a “go live” licence, which means that you are allowed to use it in production.

The download site provides the following beta 2 editions:

With the release of beta 2 Visual Studio 2008 is now feature complete.

My favorite new features are partial methods and extended LINQ support. S. Somasegar and Scott Guthrie have provide a Channel 9 video on the new features. Have a look at the extensive list of new features on Scott’s blog, too.

Posted by Hartmut Wilms at 10:39

29.06.07

The Rails Question & the .NET Open Source Dilemma

 

Harry Pierson examines The Rails Question,  asked by Nick Malik, in his blog: “what is the Rails “answer” on the Microsoft platform?

At first Pierson readily refers to the Microsoft Dynamic Language Runtime (DLR) team, which will provide a Ruby implementation on the .NET platform. In order to be accepted this implementation has to incorporate a Rails implementation. Then he muses about an alternative: “can ASP.NET evolve to be more Rails-esque?”.

The answer is … yes … perhaps. He even mentions the Castle Project, which has an ASP.NET implementation inspired by Action Pack:

The Castle Project has an ASP.NET implementation of MVC (aka MonoRail) and Active Record (also called Active Record). But I assume Nick’s more interested in what ships natively in the platform to compare to Rails.

I completely agree with him that MonoRail provides a very good way of programming ASP.NET applications the “Rails-esque” way. What strikes me (again and again) is the second part. It’s one of the many examples that the .NET community (for the most part) ignores Open Source Projects. The (only) reasons why: it doesn’t ship “natively in the platform”, i.e. it’s not “approved” by or coming from Microsoft. Stupid!

The Java community has benefited a lot from the many Open Source projects. In fact Java probably wouldn’t have succeeded without them. In the .NET world OS projects are mainly ignored, which in turn leads to abandoned projects, bad support and less initiatives. This is a dilemma only the community can solve …

Posted by Hartmut Wilms at 21:15 | TrackBack

05.06.07

Interview: Jezz Santos about Software Factories

My interview with Jezz Santos, a trusted expert advisor for the Web Service Software Factory and the creator of one of the world’s first implementations of a software factory (the ‘EFx Factory’), which demonstrates some of the advanced features of a future generation of software factories to come from Microsoft, is published on InfoQ, at last.

Go read it here.

Posted by Hartmut Wilms at 19:25 | TrackBack

14.05.07

SOA.NET news on InfoQ

I completely forgot about announcing my activities on InfoQ as a news contributor. So here I go:

 

Since February 2007 I’m contributing news to the .NET and SOA community on InfoQ. Please have a look at these and all other InfoQ  communities for news, articles, interviews, presentations, and books on Enterprise IT matters.

 

I will continue to state my personal opinions (on these and other matters) in this blog.

Posted by Hartmut Wilms at 16:35 | TrackBack

11.04.07

Partial Methods: the Missing Pieces of Code Generation

Partial Classes, a C# 2.0 language feature, are mainly used within code generation. What’s missing today is a means of customizing generated methods. Let’s say your code generator generates a method, which does “something”:

private void MyGeneratedMethod() {
    ...
    // Do Something
    ...
}

If someone wants to add any kind of pre- or post-processing surrounding this “something”, he’s out of luck. Traditionally this problem is solved by introducing protected areas into the generated code. These areas contain code, manually added by the developer, which is “protected” from being eliminated by subsequent code generations. The code generator has to identify these areas and act accordingly. The “protected areas” approach isn’t fool-proof, because protected areas can easily be removed without notification. Partial Methods to the rescue:

 

// In MyGeneratedClass.generated.cs 
public partial class MyGeneratedClass { 
 
    private void MyGeneratedMethod() {
        MyGeneratedMethodPreprocessing();
        // Do Something
        MyGeneratedMethodPostprocessing();
    } 
 
    partial void MyGeneratedMethodPreprocessing(); 
    partial void MyGeneratedMethodPostprocessing(); 
 
} 
 
// In MyGeneratedClass.cs 
public partial class MyGeneratedClass { 
    partial void MyGeneratedMethodPreprocessing() {
        // Do some preprocessing
    }
    partial void MyGeneratedMethodPostprocessing() {
        // Do some postprocessing
    }
} 

Partial Methods separate method definition and implementation. A defined method does not have to be implemented, i.e. if a partial method definition isn’t implemented, all calling code is removed by the compiler.

Galin Iliev summarizes the restrictions on partial methods in his blog entry:

Posted by Hartmut Wilms at 17:32

08.03.07

Jeremy D. Miller - Do you use OSS tools for .Net development?

 

Jeremy Miller started an informal poll asking “Do you use OSS tools for .Net development?”.

Does your workplace routinely employ Open Source tools for software development with .Net?  If not, why not?  Based on experience, I can probably make some guesses, but I’d still prefer to hear it from you.

  • OSS isn’t supported
  • Untrustworthy quality
  • Company policy
  • Don’t know the alternatives
  • We only use Microsoft tools

I’m very interested in this question, too. I’ve got a strong Java background and have been using OSS tools very often. The experiences have been good and bad. Today I’m mainly using the .NET editions of the most famous Java OSS tools:

Compared to my Java projects this is a very small set. At the moment I’m playing with

Until now I’m very pleased with the tools we’re using. Thus I’m recommending them to you!

Posted by Hartmut Wilms at 12:14 | TrackBack