.NET

Lately I’ve been trying to include a call to a REST service using the WebAPI client to a library already used from inside both an ASP.NET page and a WCF service. The problem with mixing sync and async Of course I started with an async/await code: HttpResponseMessage response = await client.PostAsJsonAsync(GetUpdateUri(), payload);
Unfortunately both consumers were synchronous, so I had to wait for the async to complete before going on with the execution: so I did something that proved to be wrong (the following methods calls the line...

It took me a while to find out the (very simple) solution to my problem, so I thought it would have been a good idea to create a post explaining it. The problem I’m logging from my application using Enterprise Library Logging component, and I wanted to have a new file every day. So I configured the logger with the RollingFlatFileTraceListener. One of the properties you can specify during the registration is the rollInterval attibute, which configures the log to roll every minute, hour, day, week, month, year. I wanted to have a new file every day,...

I just came back from the Microsoft MVP summit, where they announced (to MVPs) lots of interesting news about the future of web development with .NET: many were already well known like the new ASP.NET vNext and ASP.NET MVC 6, but other were pretty new also for us MVPs. Unfortunately, despite being super-excited about them, I cannot tell you anything as everything is under NDA. I can tell you though that this Wednesday and Thursday, there will be a virtual developer conference, Connect();, where many of the news will be revealed to the World. Specifically, on...

All developers like to personalize their IDE, and even if lately I’m not doing that much of coding, I still like to have my Visual Studio 2013 “pimped” with the extensions that make work easier and faster. Here is a list of the extensions I’ve installed on my VS2013. ReSharper I guess this tool doesn’t need introductions: refactorings, code completion, code quality and coding standards checks and many other little helpers that make coding faster. It’s a commercial tool that costs 134€ and comes with a 30 days trial. More info on JetBrains’ web site. Nuget...

Continuing with my series of posts inspired by the work done on the Web.NET Conference web site, after telling you why you should not use Boolean fields when modeling your objects, today I want to share with you an ActionResult I wrote to get a CSV from a generic list of object. I needed to download the list of all attendees in csv format so that I could import them into Excel for doing various free-form analysis: I looked around the net to see if something was available but I found nothing, so I decided to write it myself...

Over the last few months I worked, on my spare time, on a new web development project: the site for the Web.NET Conference. It was a refreshing experience, going back working on custom development on ASP.NET MVC 4 and all the latest bits of technology. That gave me quite a few ideas for posts, so over the next weeks I'm going to blog about some of the bits and pieces of code that I think are worth sharing with the community, like ActionResults, HtmlHelpers together with my first real-coding experiences with RavenDb. As first post I’m not focusing...

Asynchronous operations in ASP.NET MVC have always been left a bit behind. They appeared in ASP.NET MVC 2, remained untouched in v3, but now in MVC 4 (especially in combination with C# 5 and async/await) they reached the same easiness of use of the standard synchronous controller. Now (or better, in a few months with the release of ASP.NET MVC 4, .NET 4.5 and C# 5) you can write public async Task<ViewResult> Stuff()
{
return View(await DoStuff("Some stuff"));
}
In this post I’m going to show how the code...

Last week I registered to the Agile .NET 2011 Europe conference, held in Gent, on 10 - 11 October, and I’m really looking forward to it. I think that if you live in Belgium (or near Belgium) and are into .NET development this is a conference you cannot miss: 2 days of sessions about Agile Principles and Software Craftsmanship with .NET flavor, and at reasonable price (350€ till end of September and 450€ later, using the coupon code, 300€ till the end of September and 400€ afterwards) and good (IMHO, better and cheaper) replacement for the cancelled StackOverflow DevDays in...

In the previous years “n books for a .NET Summer reading list” used to be the title of the book list post. Now, in the last of my 4 posts with books suggestions I am back to the original title. In my introductory post I said I would have listed only a few web development on .NET books. In fact there are only 2. Web Development on .NET Professional ASP.NET MVC 3 While Professional ASP.NET MVC v2 was mainly an update of the original professional MVC1 book, the third remake, due to the nature of the new...

This August, if you are on holiday and are not in snorkeling in a lagoon in a tropical island, or if you are work but not many things to do due to the summer period, you could spend half an hour (or half a day, or a full day) getting up to speed with the latest cool technologies of the moment: HTML5 Windows Phone 7 “Mango” update Azure Visual Studio ALM (well, this is not as cool as the others, but as...

One of the disadvantages of using an ORM is that your application doesn’t know which SQL commands are being executed. In this post I’m going to show you how to log all the SQL statements that are executed by Entity Framework. This is very useful if you want to look at the query executed and the time take by each to catch some possible pitfalls, or to keep a log of all the commands executed if you have your own custom replication/synchronization strategy. The need I was exactly in that latter scenario: the backend acts on one DB,...

Lately I’m working together with Daniela on a news feed reader for WP7 and one of its features is Google Reader synchronization. (It is called FeedTso, and if you are interested in knowing when it will be released I recommend you go and subscribe to the newsletter on the FeedTso site.) I’ll talk about the Google Reader API in a future post (I’ll opensource the API when FeedTso is on the MarketPlace) but for the moment I want to discuss how I deserialize the JSON Date that I receive from the Google Reader API (and from what I’ve been...

Back from the holiday an nice surprise was awaiting for me: I’ve to “finalize” (as in make it work) an application that someone that left the company developed more than one year ago. Among the other problems one real surprised me: the project is built with .NET 3.5 and uses Entity Framework v1 and in some the queries failed with the following strange error: Only parameterless constructors and initializers are supported in LINQ to Entities. Just to be clear, it was a runtime error, not a build failure. The queries that were failing...

In this post I’m going to explain the reason behind my decision to introduce Lucene.net into Subtext to power the internal search engine.
The problem: high bounce rate
It all stared a few week ago, when I noticed that I get lot of visitors from search engines (around 70%) but that they rarely look at more than one page (only 15% read a second page).
I was interested in knowing if this was just a problem of my blog, or a general problem of all tech/dev oriented blogs. So I ran a quick poll over twitter, and I found out that I’m not...

Many new things came out before the actual keynote, like ASP.NET MVC RTM, Silverlight 3.0 Beta 1 (with Blend for SL3 and its VS2008 tools), RIA DataServices. Not sure if it was something they planned or an error by someone that forgot that 9AM in Las Vegas happens 8 hour after 9AM in Europe, but that’s what we’ve got. The Opening keynote by Buxton I would have never expected such an awesome keynote by Buxton: it was about user experience designer, about UX in MS, about the importance of sketching. Buxton is a researcher, but it was one...

Ninject with ASP.NET MVC series How to use Ninject with ASP.NET MVC How to use Ninject to inject dependencies into ASP.NET MVC ActionFilters Extending Ninject to inject dependencies into Action Filters Ninject.FilterInjector v1.5: now injecting inside all filters ActionFilters are a great way to encapsulate pieces of functionalities and move them outside ASP.NET MVC Controllers, but they have a problem: it’s very difficult to inject dependencies...

If you want to get started with Azure, you might be interested in listening to the 4 last episodes of ASP.NET Podcast, by Wally.
Episode 131 is a general discussion about Cloud Computing in general (MP3 only).
Then things get more interesting, and Wally talks about two of the main components of Windows Azure: Blob Storage and Table Storage. These two episodes are screencasts that show how to setup the development environment, how to use the local Azure fabric and the how to create a simple CRUD application.
Then the last episode (#134) is the a wrap up show, with general thought on...

A bit late for my Xmas present, but today I received my copy to the book written by Andrea Saltarello and Dino Esposito: Microsoft® .NET: Architecting Applications for the Enterprise. I’m not sure when I’ll be able to start reading it, but given the synopsis and excitement with which Andrea announced his book (in Italian, sorry) I think it’s going to be a great book, a must have for every .NET developer and architect out there. Too bad I’ve to wait next year to have Andrea sign my copy of the book. Technorati Tags:...

As PDC goes one, other sessions are being redistributed online as downloadable videos. I already wrote about the sessions I downloaded from the first two days @ PDC 2008, but now more from day two and from day three are appearing online: Oslo: TL27 - "Oslo": The Language - Don Box, David Langworthy Velocity: TL14 - Project "Velocity": A...

I’m not at PDC 2008, so I’ve to keep up with what’s being announced in LA only through videos. I watched the two keynotes live (for those who missed them, they are available on demand from the homepage of PDC site). But there are many other interesting videos to watch. Here is a list of the ones I’m downloading and I’m planning to watch over the next days (well, probably nights): ASP.NET and Web Development PC20 - ASP.NET 4.0 Roadmap - Scott...

Far from me to start yet another religious war, but on the blog a friend from the Italian User Group I found a very amusing cartoon about .NET and PHP in the enterprise (made by David Betz in February 2008), so I thought it would have been funny to repost it here.
The original post seems to be unreachable but when I first saw it, I read that there should be other comic strips on that topic.
UPDATE: Seems like the original site is back to life, here is the second comic strip.
Technorati Tags: php,asp.net,comics

Seems like the Borgification of the opensource .NET community is going on: Hamilton Verissimo aka Hammett, the father of Castle, is joining Microsoft as the PM on the MEF (Managed Extensibility Framework) team. Congratulation to Hammett for the achievement, and hope he has fun moving from the sunny São Paulo to rainy Redmond. The good thing is that he will continue working on Castle. How’s next? Ayende? or Scott Bellware? Technorati Tags: Hammett,Castle,Microsoft,MEF

A few days ago I installed the VS 2008 Web Development Hot-Fix Roll-Up but yesterday I found a strange bug: when I wanted to create a "new web site" I had an empty dialog, with no project templates and all the field disabled. On the original post I found a comment from someone with the same problem and ScottGu told him to send him an email: I did the same, Scott answered in a few hours saying that someone will have handled the issue. A few hours later I got an email from Mikhail Arkhipov from...

Microsoft Surface and Jeff Han's multi-touch UI seem to be ages behind if compared to Project Maestro, developed by Cynergy, a RIA development company based in Washington, DC.
What Project Maestro is?:It's a prototype of a no-touch interface, developed with WPF, XAML and using the WII remote with some custom-built IR gloves. And they say they built it in 8 days.
Here is the video of how it works:
If you want to do it yourself, here are some pointers to get you started: Connecting the Wii Control to WPF and the Wiimote project.
Seems like we are not far from revolutionizing the way...

One of the best feature that is in mbUnit since 2004 is RowTest, which is the ability to perform the same test using different input data and expected results. RowTest [RowTest]
[Row(1,1,2)]
[Row(2,1,3)]
[Row(1,-1,0)]
public void SumTest(int a1, int a2, int result)
{
Assert.AreEqual(a1 + a2, result);
}
The cool thing is that each "row" is treated as a different test, and if the test fails for one set of data, the others might not. And this helps pinpointing the data that are making the test to fail.
This week I was adding...

I just spent a few hours banging my head against a XPath query that didn't return the node I was trying to select using the right xpath string: to make a long story short, if your XML document has a default namespace without any prefix, to make XPath queries on it you have to use a NamespageManager, add the default namespace with a fake prefix, and then query the document specifying the namespace manager in the SelectNodes method. But let's explain a bit more in detail. Imagine you want to make a XPath query on a VisualStudio project (the...

I thought I already mentioned it previously, but probably the things that happened to me in the last month made me forget to mention it. But going to the point, my Belgian Kiwi friend Ivan is starting to write a book about IronRuby. Congratulations Ivan!! Technorati tags: IronRuby, Ivan, book

After the initial release of the Team Suite on the MSDN, I just saw that also the VS 2008 Express Editions and the trial versions of VSTS (Professional version still to come) have been released. In addition also the .NET Framework 3.5 is available as standalone download. And while we are talking about VS2008 related downloads here are a few others I think are quite useful: Soma, Carol Grojean, Jeff Beehler announce the release of Visual Studio 2008 RTM (WMV) Visual Studio 2008 and .NET Framework 3.5 Training Kit, 120Mb with labs, demos and PPTs VS2008 samples,...

Tomorrow, October 17th, I'll be at Mono Day, an event organized by Novell to spread the word about this Open Source project, sponsored by Novell, that implements the .NET API and allow .NET software to run on Linux, OS X and Unix.
I read the agenda and it seems that the only interesting part of the event is the last speech, by Massimiliano Mantione, developer part of the Mono core team. The rest is just promotion of Novell products and partnerships.
I hope the "Mono from the source" speech will be the main part of the event, and the other only a...

I wanted to write my opinion about the ALT.net thing since a long time, but I really never find the time to sit down and organize my ideas into an organic post.The event that "triggered" this post is my friend Lorenzo asking my opinion about his blog post "There are architect and Architects" (it's in Italian but here is the link to the auto-translated version by Google). In his post Lorenzo, commenting on Sam's post about leaving CodeBetter and ALT.NET, adds some thoughts about something that usually the hard-core ALT.NET people don't get: imagine you have an Enterprise-level project,...

Two years I developed, for the company I worked for in Milano, a video news website that runs inside the Windows Media Center, in the Italian spotlight section. The site is an Hosted HTML Application: a normal HTML page that can interact with its host (the mediacenter process, not IE) via specific JavaScript API. Today I was listening to the last episode of Hanselminutes about development on the Media Center for Vista, and I found out that the new version of the platform adds a new way of developing application on the Media Center. The old way (XP/MCE) With Media Center...

As we all know the chip industry changed it's approach to performances increment: we will not see 10Ghz processors (not even 5Ghz ones), but now we have duo-core, quad-core and 8-core or 16-core processors coming in a near future. But this is a problem for software developers: while it's easy to take advantage of a 10Ghz processor (just do what you always did, and your application will go faster because it will be run by a faster processor), it's more difficult to take advantage of four 2.4Ghz cores inside the same processor. A few years ago, Volker Will said: But how will...

What is the Unicode Byte Order Mark (BOM)? Every Unicode string starts with a "zero-width no-break space"; depending on its actual byte representation, a text processor understands the endianness of the characters that follow the BOM. For example, in UTF-16, if the first character of a string is represented as FE FF it means that the bytes in the string are represented using the Big Endian order, while if the string was using the Little Endian order, the first character would have been represented as FF FE. This rule apply only to UFT-16 and UTF-32 encoded strings, and not to UTF-8 (since there is just...

Ivan and the other guys in Wellington had their last Lunch with Geeks about Design Patterns. And came out with that idea: The most overused design pattern : Singleton. With the remark that a singleton should only be used when you need to keep state in your object internally. So, just to reinforce that concept, here is a VS2005 code snippet to quickly create a Singleton. I uploaded it on GotCodeSnippets.NET, a repository of code snippets. Download the Singleton VS2005 code snippet. It expands to the following code: public sealed class Singleton
{
private readonly static...

A bit later then what I planned 6 months ago, today I just passed 70-536: Microsoft .NET Framework 2.0 - Application Development Foundation.
I passed with 806 with a passing score of 700, but making a few calculation I didn't understand which would have been the maximum score since if 700 is 80% of the max (as in the practice tests), the max would have been 875.
But 806 out of 875 means 92,114%, that means that I correctly answered 41,45 questions, which is impossible.
Anyway, a good result since I seriously studied for the exam only one week of evenings. And I...

>>>>>>> Oh, and I'm desperately waiting for the VS2K8 Beta 2 - will it be dropped soon? You'll see Beta2 ship later this week - so only a few more days now.Thanks,Scott ScottGu wrote that Beta2 will ship later this week in a comment on his post announcing IronRuby. And it's said to be 99% feature complete. I think I can exceed my traffic cap next week. Technorati tags: visual studio, Orcas

The POSIX time, or Unix time, is the number of seconds elapsed from the midnight of January 1st 1970 in UTC coordinates. This timestamp is used in all *nix languages; probably you will never need to use a Unix timestamp in .NET, but if you have to interact with other application or sites, maybe built in PHP or Java, you will probably have to deal with it. But .NET doesn't have a method to convert a Unix timestamp to a DateTime and viceversa (or I didn't find it), so I had to implement it. static DateTime ConvertFromUnixTimestamp(double timestamp)
{
...

Today I started getting a strange exception every time I try to enter a character in a textbox: LoaderLock detectedAttempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang. But I was just typing a character in a test application with only a textbox, not doing anything so exotic. After banging my head against the wall for a few hours I found on MSDN forum a strange compatibility issue between Visual Studio 2005 and iTunes 7.1: LoaderLock detected, only when...

Sergey Koshcheyev, project leader of NHibernate, just announced the release to the world of NHibernate 1.2. NHibernate 1.2 has been in beta testing for the last half year. Today it is officially marked stable, production-ready, and supported. What are the most compelling new features and why should you upgrade? Just a brief overview of the new features: there is a commercial support: I guess that the lack of that is one of the things that scares "traditional" IT managers the most Native support of generics Support for Stored Procedures SysCache2: a second level cache provider based on the...

Michael Schwarz, the creator of Ajax.NET, the first .NET library to enable Ajax, just wrote on his blog a nice feature to feature comparison of MS Silverlight and Flash/Flex:
Rich Media Platform Comparison
I don't get the why he (or better the original source) included in the comparison also .NET 3.0, which is a completely different beast.
Anyway it turns out that they are basically the same for Rich Applications, but Silverlight, being based on WMF, has a lot more features (DRM, HiDef, production tools) than Flash in the video field.
Technorati tags: silverlight, wpf/e

I just had to collect a list of links about the new features of ASP.NET 2.0 for my colleagues since our next project will be ASP.NET 2.0 and will leverage almost all of that features, so I think is worth sharing it. Membership/role/profile API: for managing account, login, administrative permissions, and so on (and you can build a custom provider that gets data from a legacy database) Using the Membership and Role Manager API: http://quickstarts.asp.net/QuickStartv20/aspnet/doc/security/membership.aspx Introduction to Membership: http://msdn2.microsoft.com/en-us/library/yh26yfzy.aspx Implementing a Membership Provider: http://msdn2.microsoft.com/en-us/library/f1kyba5e.aspx SiteMap: bound with the feature above, will make very easy the process of limiting...

After a few month of beta, Microsoft finally release the final version of the Visual Studio 2005 Service Pack 1 update that specifically targets problems running on Vista. I installed the beta a few months ago, just a few days after starting to work here at Calcium, and I didn't have any notable issues. You can download it from Microsoft Download Site: Visual Studio 2005 Service Pack 1 Update for Windows Vista

After a nice 4 days trek on the Marlborough Sounds (pictures and short report to come soon), I'm back at work. We are close to the release of the next version of our main product, so we are setting up some VirtualPCs to test it. And we found a problem on a portion of application that never caused problems: a simple Clipboard.SetDataObject. Looking at the documentation on MSDN I found that NET 2.0 added a new overload to the SetDataObject method: public static void SetDataObject (
Object data,
bool copy,
int...

The Microsoft Platform Evangelism team released a very nice technology demo product to show all the new cool technologies Microsoft just released or is going to release during that year. The demo utilizes several technologies including: IIS7, ASP.NET Ajax Extensions, Linq, Windows Communication Foundation, Windows Workflow Foundation, Windows Presentation Foundation, Windows Powershell, and the .NET Compact Framework. They are developing the demo on CodePlex, so you can download the code directly from there. The also build a web site DinnerNow.net, that will contain a working demo, and will host videos showing the features of the "product". At the moment...

Yesterday afternoon I delivered my first speech in English: NHibernate in 8 minutes during the Lightining session at the Wellington .NET user group meeting.
I hope my English was not too bad, and that I managed in making a brief overview of the power of NHibernate.
If you attended my presentation, please write a comment about it, and also if you would like to listen to a more detailed presentation of NHibernate.
For the moment you can download the slides and the demo of the Lightning presentation.

UPDATE: This is about .NET 2.0 Certification path. Here is the update about the new .NET 3.5 certification path.
Today I was looking for an explanation of the new Microsoft Certification paths, but I was not able to find a brief one and I had to review all the pages on the Microsoft Learning site to have a comparison of them all. Here is what I found:
There are 3 version of MCPD:
MCPD Web Developer
MCPD Windows Developer
MCPD Enterprise Application Developer
The first two certifications (web and windows) consist of 3 exams. Enterprise Application...

Owen Rogers sent the announcement on the mailinglist a few minutes ago. CCNET has a new version: 1.2. Here are some of the new features: - automatic checkout from svn and cvs (there are performance improvements for cvs as well)*- project-level view of the server log through the webdashboard- better clean up of child processes for more rapid stop/restart of the ccnet server- better mono support- view a project's configuration through the webdashboard. And go to the project website for the complete release notes. If you are a CVS user you need to change a few things in your...

A month after my first try, yesterday I tried again. I started at 8:30pm stopping all useless programs (RSS Readers, Outlook, Skype, Gtalk, MSN Messenger and all that sort of stuff). Then I stopped almost all window services running, and cleaned all the temp folders (one of which still contained some stuff - 430Mb - remaining from the other try). Ready, set, go!!! 15 minutes for the patch to extract itself to a temp folder, then other 10 minutes for the MSI to configure itself. Finally I get the "Do you want to install the Service Pack 1 for Visual Studio 2005..."?...

In my first week of work in Wellington at Calcium, I'm starting to migrate the application from .NET 1.1 to .NET 2.0. The wizard did correctly almost all of the job, and the only thing I needed to change to make it compile without too many warnings was changing the old (and obsolete) Parameters.Add with the new Parameters.AddWithValue (I think I did it 1000 times). Once it compiled we had a very strange problem: we are sending username and password, encrypting them using TripleDES, then serializing as string and then sending over the wire with remoting. And of course decrypting them...

Just before Christmas a new version of DotNetNuke has been released. 4.4.0 is the new version number and, unlikely the previous releases, it is not accompanied by a 3.4.0 version: this means that there won't be any more .NET 1.1 compatible DNN release. And, IMHO, who needs new 1.1 compatible releases? The 4.4 has many new features, mainly concerning performance and scalability improvements. Here is the the release announcement. To have a better understanding of which are the new performance improvements I recommend reading the posts that Shaun Walker wrote almost a month ago: Windows Hosting Performance & Scalability Performance Enhancements One...

Yesterday evening, just arrived home after my speech at the DotNetMarche UG, I downloaded VS2005 SP1
This morning I read on ScottGu's blog:
...can take 30-90 minutes to update your Visual Studio 2005 installation depending on which versions of VS you have installed, and what features are enabled. So you should plan ahead and not expect it to be a few second operation (note: it is a good task to kick off before lunch or in the evening).
So I uninstalled the VS 2005 Web Application Project update and I launched the SP just before going downtown for the last Christmas gifts.
I came back home...