The mysteries of software development and networking... RSS 2.0



 Wednesday, April 23, 2008

Array conversion, or reshaping of objects, seems like a cool thing to do with LINQ and C# 3.0.
I've played around a little with the following:

sbyte[] imageBytes = GetImage();

// convert using extension method / Lambda syntax 
byte[] y = imageBytes.Select( s => (byte) s ).ToArray();

// convert using LINQ syntax
byte[] x = ( from b in imageBytes select (byte) b).ToArray() ;

// convert using the Cast extension method
byte[] z = imageBytes.Cast<byte>().ToArray();

So what is the difference? Actually approach 1 and 2 lead to the same IL.
The Cast method works quite different and in my case I got an exception from approach 3 saying the sbyte would not fit in the byte.

But of course LINQ is not needed for this simple conversion:

// convert by casting to array to byte[]
byte[] bytes = (byte[])(Array)imageBytes;

I did a quick perf check and the last option is 500 to 800 times faster.

 

Wednesday, April 23, 2008 11:10:52 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
C#
 Monday, April 21, 2008

The Maine Developer Network is hosting a Geek Lunch tomorrow at the State of Maine, Harlow Building at 18 Elkins Ave in Augusta.
Chris Bowen will be presenting on LINQ & Language Improvements in C# 3.0/VB 9.
Sign up here.

LINQ (Language Integrated Query) is a unified approach for querying data using coding syntax that remains consistent regardless of the data source. It WILL change the way you work as a developer and architect and this session will help you on your way to using it effectively. To understand how LINQ works, we'll first navigate the new features of C# 3.0 and VB 9.0 that enable LINQ functionality. Then, we'll dive into .NET 3.5 and Visual Studio 2008 to explore the various realms of LINQ: Datasets, XML, Database/SQL, in-memory objects, and more. By the end of this session, you'll have a solid understanding of how LINQ works and what it can do for your applications.

Monday, April 21, 2008 8:50:10 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
C# | General | LINQ
 Wednesday, April 09, 2008

Background: Assume we have workflow which is hosted as a WCF service. Every workflow instance is identified by the workflow instanceId. When a remote call comes into the workflow runtime the runtime needs to identify which workflow instance the caller wants to communicate with. If no identification is provided the runtime will assume a new workflow instance needs to be created.

Consider the following piece of client side code which calls a workflow service called FirstOperation() which is handled by a ReceiveActivity on the server:

ClientProxy proxy = new ClientProxy();
proxy.Open();
proxy.FirstOperation(); //creates a new workflow
proxy.Close();

Now assume a second call needs to be made and the second call needs to be handled by the same workflow because in this workflow there is second ReceiveActivity waiting for the SecondOperation to be called.
The following piece of code will do just that:

ClientProxy proxy = new ClientProxy();
proxy.Open();
proxy.FirstOperation(); //creates a new workflow
//.. more code, keep the WCF channel open
proxy.SecondOperation();
proxy.Close();

The above code will work because the ReceiveActivity in combination with the WorkflowServiceHost automatically adds information to the WCF context. The instanceId of the workflow has been added to the context. The above code is bad design. The connection to the server is a valuable resource and should be closed as soon as possible. The following code snippet show how the context manager is used to retrieve the context from the call which initiates the workflow and is then reused when a new client proxy is created.

ClientProxy proxy = new ClientProxy();
proxy.Open();
proxy.FirstOperation(); //creates a new workflow
IContextManager manager = proxy.InnerChannel.GetProperty();
IDictionary context = manager.GetContext();
proxy.Close();

//.. more code, the WCF channel is now closed

proxy = new ClientProxy();
IContextManager manager = proxy.InnerChannel.GetProperty();
manager.SetContext(context);
proxy.SecondOperation();
proxy.Close();

The IContextManager has been added in .NET 3.5 to help with correlation. The code needed in .NET 3.0 to achieve the similar functionality is much less elegant.

Note 1: Server side both the ReceiveActivity as well as the SendActivity have a Context property allowing for easy access to the context. A common pattern for implementing a callback is to set the context of the SendActivity to the value of the context of the ReceiveActivity. In the scenario illustrated above the context would consist of just the instanceId. In scenarios where the workflow is using send and receive activities within a parallel activity the context will automatically get extended to include a conversationId, allowing the WorkflowServiceHost to correlate an incoming call to the correct receive activity.

Note 2: If you want manually add the instanceId to a context, have a look at this post by Maurice de Beijer.


Wednesday, April 09, 2008 1:59:06 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
WF
 Monday, April 07, 2008

The Boston Code Camp 9 is over and done with. It was a great two day event and kudos to Chris, Chris and all the presenters that put their time and effort into making this an excellent happening!

Here are the two presentations from the session that I did:

04-06-2008 CC9 - Building a State Machine Workflow.zip (231.61 KB)
04-06-2008 CC9 - Building applications with logic.zip (1.78 MB)
Monday, April 07, 2008 10:20:18 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
Architecture | C# | General | WF
 Tuesday, April 01, 2008

If you're interested in playing around and testing VSTS 2008 and TFS 2008, but don't want to waste too much time getting the software installed? Good news! The trial Virtual PC images have been updated! Download your play area right here.

The image will not expire until December 31st 2008.

"This virtual machine is running Windows Server 2003 Enterprise Edition, SP2. It contains a full installation of Team Foundation Server 2008, Team Build 2008, Team Explorer 2008, Visual Studio Team System 2008 Team Suite and all necessary prerequisites. In addition, it has been updated with Office 2007 SP1, current Windows Updates as of March 25, 2008, and the December Release of the TFS Power Tools. Team Foundation Server is installed in workgroup authentication mode and thus does not require a domain controller. "

Tuesday, April 01, 2008 11:48:24 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
Team System

The Bangor Area .NET Developers are meeting tonight at the Hampton Inn, Bangor (directions).

Converting VB6 Apps to .NET – Eric Burdo

You feel stuck in VB6 land...there is all this .NET stuff people are talking about.  You know you want to get there, but what does it take?  Eric will show you!  Come learn how to make the jump from VB6 to .NET and find out some of the pros and cons to converting your older apps.

Plus there's a random drawing for your own wireless desktop (keyboard and mouse), among other cool door prizes!

If you haven't done so already: Register For This Gig.

Tuesday, April 01, 2008 9:39:15 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General

Today is a good day for a laugh... I love this one.

:-)

Tuesday, April 01, 2008 9:21:48 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General | Team System
 Friday, March 28, 2008

Chris just posted the schedule for Boston Code Camp 9!

Go to: http://blogs.msdn.com/cbowen/archive/2008/03/28/code-camp-9-the-schedule.aspx.

See you next week!

Friday, March 28, 2008 11:26:28 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General
 Thursday, March 27, 2008

I've blogged before about the availability of design specs on the next version of Visual Studio Team System. Well, another group of Rosario specs have been recently published on the Rosario Specs website:

 

·         TFS Bug Submission Portal

·         Send Mail from TFS

·         Work Item Tracking Linking

  

If you feel like participating visit the spec discussion forum.

Thursday, March 27, 2008 1:34:06 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
Team System

Since I was looking at books today anyway I thought I'd research what is available C# 3.0, I haven't read any of these yet, but check them out:

Thursday, March 27, 2008 12:34:28 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
C# | LINQ

A friend of mine asked me about what book I'd recommend for learning Windows Communication Foundation.

I've read 'Learning WCF' from Michele Leroux Bustamante and think it's great and I still use it as reference material.

Thursday, March 27, 2008 10:40:50 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
WCF
 Wednesday, March 26, 2008

The Boston Code Camp 9 "I Came, I Saw, I Coded" will be held on April 5th and 6th at Microsoft New England District: 201 Jones Rd, 6th Floor, Waltham MA USA.

There are over 50 sessions planned (http://www.thedevcommunity.org/Events/PresentationList.aspx?id=6) and I will be presenting on two topics:

Building a State Machine Workflow
Workflow Foundation offers 2 types of workflows, sequential and state machine. This presentation walks through the process of building an application using a State Machine workflow, including state design, state transitions, data exchange services and handling external events.

Building applications with logic
This session presents a view on how datasets and business logic can be organized to build a working application.
Use basic architectural patterns to enable team development and improve maintainability of your sources.

Hope to see you there!

Wednesday, March 26, 2008 12:16:51 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General
 Monday, March 24, 2008

The 22nd of April the Maine Developer Network is organizing a Geek Lunch. We'll be meeting at the State of Maine offices in Augusta to listen to Chris Bowen present on LINQ & Language Improvements in C# 3.0/VB 9.

Pizza will be provided and attendance is free and open for everyone!

More info and RSVP here.

Monday, March 24, 2008 11:52:01 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
C# | General | LINQ
 Sunday, March 16, 2008

My article for the Software Developer Network Magazine has been printed in the magazine. If you don't receive the magazine you can read the article here.

Sunday, March 16, 2008 10:39:07 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
AOL | Vista
 Thursday, March 06, 2008

Slowly but surely more website are starting to support CardSpace. I’ve recently blogged about using Cardspace in conjunction with an OpenID from MyOpenID.com to log on to http://dev.aol.com/. Just the other day I discovered that that my hosting provider has started a beta program allowing me to sign on to my website’s control panel using CardSpace. Never one to shy away from a beta program I gave it a swirl.

After logging in to the website using my regular username/password I proceeded to my account page. Here a new button has been added ‘Bind card to account’, after clicking the button the CardSpace cardselector on my Vista machine opened up and I was allowed to select a card. Press OK and all was good. Time for a little test. Log out of the website. Then go back to the logon page and now instead of using my username/password I can use my CardSpace card to logon. And sure enough it worked!

Next came the real test. Since I also have DiscountASP hosting the website for our user group (Maine Developer Network) I tried to logon to this account using my CardSpace card. While doing so I discovered that this did not work. I could not bind the same card to two different accounts. I had to dive in a little deeper, but soon discovered this not to be a limitation of CardSpace, but rather, the website does not support multiple accounts to one card.
The way to solve this would be to implement an account selector which would become available after logging using the CardSpace card. The same would be true if DiscountASP would support OpenID. Then one ID would have to be attached to multiple accounts.

Moral of the story: We’re a long way away from the ‘one ID to rule them all’. There is more to it than replacing your username/password validation with an OpenID or CardSpace control. You will have to reconsider the relationship between user accounts and your customer.

Thursday, March 06, 2008 1:49:26 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
Architecture | General

Silverlight 2.0 beta 1 is offering a DataGrid out of the box. Kathy Kam has a a great sample app showing off all the controls in Silverlight and providing you with a view of the underlying XAML.

Haven't installed Silverlight 2.0 yet? It'll install automatically, but you will have to restart the browser (at least, I had to).

Thursday, March 06, 2008 1:25:44 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
Silverlight
 Wednesday, February 27, 2008

The next version of Visual Studio Team System and Team Foundation Server is codenamed "Rosario". No formal release date has been made public yet, but if you want to see and participate in upcoming features, then check out the spec-share page on MSDN: http://msdn2.microsoft.com/en-us/vstudio/bb936702.aspx.

Wednesday, February 27, 2008 8:48:51 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
Team System

Just a quick reminder to all who haven't RSVP-ed yet: the Maine Developer Network user group meeting this Friday is still on.

The weather forecast for Friday looks good. So hope to see you all there!

Topic
An introduction to Unit Test, Test-Driven Development and Mock Objects As software development projects grow over the course of months and years, it can be increasingly difficult to manage quality and consistency. With the help of Visual Studio 2005, Test-Driven Development (TDD) can be used with very little effort to insure constant, high-quality code is written during the lifetime of your projects. In addition, you'll see how to create and use mock objects to logically separate development efforts on different tiers of your application to prevent blocking issues.

Speaker
Speaker will be Russ Nemhauser.
Russ Nemhauser is a Microsoft ASP.NET MVP and a Microsoft Certified Professional, and has served as an Architect, Developer, Team Leader, and Project Manager over the past several years. His projects have included enterprise applications, online commerce sites, and corporate intranets for Wall Street, Universal Studios, Microsoft, Seagram, and others. Russ actively participates in the development community, speaking at several conferences and user groups each year. He also writes for several technical magazines and industry web sites.

Wednesday, February 27, 2008 8:40:49 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General
 Tuesday, February 26, 2008

On Friday the 28th of March 2008 the Software Developer Network in the Netherlands will host the 'Expedition 2008' Software Developer Event.

Below is an overview of the sessions. For more information and registration go to: http://www.sdn.nl/Default.aspx?tabid=280

Sessions

C#

Visual Basic.Net
DotNetNuke
Delphi
Inform. Worker
FoxPro
VO/Vulcan
VS2008 launch
8:30
Registratie / Ontvangst
9:00

WPF Styles & Templates

Jo-wen Mei

Workflow Foundation a la 2008

Maurice de Beijer

DotNetNuke - implementatie in de praktijk

Stefan Kamphuis

Easily migrate Delphi apps to C/S with Advantage Database 9

Joachim Dürr

Microsoft CRM 4.0 Plug-In Architectuur

Ralf van Gellekom &
 Martijn Muilwijk

On the Dark Side of FoxPro (Part 1)

Christof Wollenhaupt

Visual Basic 2008 - What's new

André Obelink

10:15
Pauze - 30 min.
10:45

Introduction Using LINQ programming model

Marcel de Vries

Ontwikkel Smart Client en Office toepassingen in Visual Studio 2008

Maarten van Stam

Enhance your modules using Token Replace

Sebastian Leupold

Delphi Agile Techniques

Pawel Glowacki

Performance Management met Performance-Point Server

Hans Geurtsen

On the Dark Side of FoxPro (Part 2)

Christof Wollenhaupt

What’s new in SQL Server 2008

Peter ter Braake

12:00
Lunch - 60 min.
13:00

C# 3.0 en Rhino Mocks maken unit testen weer interessant!

Dennis Doomen

ASP.NET 3.5 Extensions

Thomas Huijer

DotNetNuke 5: New Features

Sebastian Leupold

Samenwerking Win32 en .NET met Delphi en Hydra 3

Bob Swart

SQL server 2008: What's hot?

Donald Hessing &
 Reinhard Brongers

Werken met relationele databases in .Net en Vulcan.Net

Bert Dingemans

LINQ to SQL

Anko Duizer

14:15
Pauze - 15 min.
14:30

Domein Gedreven Programmeren met C# 3.0

A. Boonzaaijer &
 P.J. vd Sande

SQL Server 2008 - een eerste blik voor ontwikkelaars

Hugo Kornelis

Ask The Expert

Leigh Pointer

Gebruik je Delphi kennis XPlatform

Thaddy de Koning

Building Internet Sites with MOSS 2007

Donald Hessing & Marco Scholten

Webservices met Vulcan?

André Wisse

IIS 7 voor Ontwikkelaars

Sander Gerz

15:45
Pauze - 30 min.
16:15

Algemene Ledenvergadering SDN

Quality Tools in VS2008

Dennis Vroegop

17:30
Einde

Tuesday, February 26, 2008 10:36:35 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General
 Friday, February 15, 2008

On Gert 'data dude' Drapers blog there is the announcement for Power Tools for Visual Studio Team System 2008 Database Edition.

Features include:

  • Command line SQL Static Code Analysis execution through MSBuild;
  • Data Generation Wizard;
  • File based data generator;
  • XML based data generator;
  • Unique Regular Expression generator;
  • Refactoring Command Generator has been made available as a MSBuild task;
  • Two new test conditions for Database Unit Tests:
    • ChecksumCondition – Which you can use to verify that the checksum of the data set returned by a database unit test matches the checksum of an expected data set.
    • ExpectedSchemaTestCondition – Which you use to verify that the column names and data types of the returned data set match expected values.
  •  

    Friday, February 15, 2008 6:29:52 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
    Team System
    About
    This blog is run by Mark Blomsma.
    © Copyright 2008
    Develop-One
    Sign In
    Statistics
    Total Posts: 305
    This Year: 49
    This Month: 2
    This Week: 1
    Comments: 36
    All Content © 2008, Develop-One
    DasBlog theme 'Business' created by Christoph De Baene (delarou)