.NET

There are 42 entries for the tag .NET

Lazy<T> with implicit cast to T can give you some pretty code

Adding an implicit cast functionality to Lazy<T> can give you an option to writing null checkers in your delayed instantiation properties. The problem Today in our project a colleague was cussing over the fact that he kept writing the same block of code over and over again when null checking a property with a backing field. Given the class Foo: private Foo oldFooProp; public Foo OldFooProp { get { if (oldFooProp == null) { ...

Common Service Locator MEF Adapter now on .NET Framework 4.0

I like the Common Service Locator. It’s nice and clean. Abstractions are good. This is why I bothered Glenn Block about updating the MEF Adapter all the time as each version of Managed Extensibility Framework MEF came out. Finally he gave in and made me a contributor to the CSL project. – Fine – Do it your self, kind of! ;~) Glenn and I are good mates. I didn’t mind updating it just to have one thing that was in order. Hmmm… sounding bitter and disgruntled on a Saturday night, sorry. Well now the MEF release is finally...

MEF + Azure + Visual Studio 2010 = Tricky but doable (part 2)

In order to make Managed Extensibility Framework (MEF) a part of your Windows Azure project in Visual Studio 2010 while having a Test Project to test your code there is a nasty reference issue you have to resolve. I posted all the steps to resolving this issue in my recent post MEF + Azure + Visual Studio 2010 = Tricky but doable. but I forgot one step! Here is the final piece of the puzzle. The remaining problem Following the steps in my previous post (link above) you are good to go with your project in all respects...

MEF + Azure + Visual Studio 2010 = Tricky but doable

Putting Managed Extensibility Framework (MEF) in your Windows Azure Application while trying to test your code using Visual Studio 2010 does not work OOTB. It is quite easy to modify – in this case MEF – to enable this scenario. The same issue might result from using other libraries as well. Now that Visual Studio 2010 is out you really do not want to remain on the old version. Sometimes there can be issues working with applications that need to support previous versions of .NET Framework – previous to .NET 4.0 that is. Here is one such issue and...

Neo4j .NET Client over HTTP using REST and json

Here it is; a Proof of Concept of the world’s first Neo4j .NET Client. In other words: Here follows a discussion on how to create a client library for communicating with a graph database over REST. UPDATE: There is now a live CodePlex project for the realization of this concept; A .NET Client Library for Neo4j over HTTP using REST and JSON; http://neo4jrestsharp.codeplex.com/ Intro Neo Technologies have come out with a Neo4j REST API for their popular Neo4j graph database. Since I am employed at Jayway and a couple of colleagues working with Neo are too a little bird by...

Would you like a Byte Order Mark to go with that?

It is possible to encode a little bit of metadata at the beginning of your byte streams to let the stream itself carry information on how it has been encoded. This is known as a Byte Order Mark (BOM) and it is as far as we know completely optional. Some .NET Framework implementations add this BOM to the start of streams given that they are to have a specific encoding. Here is how to find the BOM, and if necessary, remove it from your stream. Context Recently Neo4j graph database announced a REST interface. A couple of colleagues...

Do I need to check a params parameter for null?

If I have a method that takes params as input. Do I need to check for null on that set of params ? Well answer is yes if you want to be really sure because there is one way to get a null into the method call. Note: I am currently working on code that I promised the Tech Ed Berlin audience when I delivered my talk Flexible Design last week. If anyone waiting is reading this – it’s on the way. I just want to make sure i document the sample so that the code may be read...

At Tech-Ed Europe brains are exploding

Tech-Talks recorded today. One on an Open Source and very much enhanced Windows Azure Project Template and another one that turned out to be a lot more “what is MEF” than I initially anticipated? And at the event at large people are looking focused on learning just as we do at the beginning of a week. I am anticipating less and less strength for focus as the week progresses. So this week I am at Tech-Ed Europe attending as a speaker on the Architecture track. Here is a brief account of the first day so far. Today anyway, apart...

Visual C# 4.0 Named Arguments

Here are how Named Arguments in C# 4.0 works. This is a very nice feature that enables better code readability and also is a must combined with Optional Arguments. We have now dug ourselves out of the crazy “method overload overload”… If you catch what I mean? I posted about Optional Arguments here: Visual C# 4.0 Optional Arguments – FINALLY Here are my sample on Optional Arguments from the last post again: public Person(int shoesize = 8, string name = "Eve", Gender gender = Gender.Female) {   } The great thing about it...

MEF Common Service Locator adapter updated to MEF Preview 6

The Common Service Locator project has a bunch of adapters. One of them is the one for Managed Extensibility Framework (MEF). I’ve updated the adapter to run on MEF Preview 6 and uploaded the result to the Codeplex site for the CSL. Common Service Locator MEF adapter Note: I’ve been nagging on Glenn Block to update the adaptor project that hooks up MEF to the Common Service Locator. Not so much nagging on him to do it, the man has enough to do, but rather nagging on him to add med as a developer on the CSL project...

My MEF session (in Swedish) from Microsoft TechDays is online

And naturally LOTS of more sessions from Microsoft TechDays in Sweden. There are some sessions that are in English as well since there were quite a few international speakers. I really have to recommend Christian Weyers session WCF Tips and tricks and… My MEF talk (in Swedish). Here is the full list: http://www.microsoft.com/sverige/techdays09/sv/sessionplanner.html Cheers, M. Technorati Tags: Services,.NET,Extensibility,Microsoft,talksThis work is licensed under a Creative Commons license.

Progressive .NET Days event in Stockholm

It is time for a Progressive .NET Days event in Stockholm on August 27-28. It’s totally gonna ROCK - you HAVE to be there! Scott Bellware @bellware: Good Test, Better Code - Context Specification and Web Testing for Developers with UI Models Ayende Rahien @ayende: Intro to NHibernate and Advanced NHibernate Udi Dahan @udidahan: UI Composition Key to SOA Success Scott K. Allen @OdeToCode: Maintainable and Modern Javascript and Internal DSLs and Fluent APIs in C# Jimmy Nilsson @jimmynilsson: Architecture for Cloud Computing David Laribee @laribee: The XP+Lean Game and Towards a New Leader Here’s...

Make screen dumps of all your screens easy in .NET!

Easy way to create a screen dump of all the screens attached to the system. You need System.Windows.Forms and System.Drawing to pull it off. My colleague Niklas Dahlman (twitter, blog) coded an elegant piece of code the other day. He can be a bit hesitant to take credit so I’ll post it for him. ;~) Our client dreamt up the idea to screen dump the current screen(s) when ever our app does a nose dive. We are currently working with a foreign exchange bank building a test framework for their very large system. Interesting work for sure and...

Learn Managed Extensibility Framework (MEF) session slides and demos

The following post will give you a resource with a good run through of how to begin coding with the core functionality of Managed Extensibility Framework (MEF) which is part of .NET Framework 4.0. Background At Microsoft Tech Days Sweden this year I presented an upcoming key part of .NET Framework 4.0; MEF. Though it might just get another product name before it ships since the abbreviation is too close to METH for comfort. ;~) I got involved with MEF because I became friends with MEF Program Manager Glenn Block just prior to his joining the MEF team....

Storing dynamically generated code to disk

Below I will show what it takes to generate a dynamic method at run-time and persist it to an assembly on disk. The assembly may later, at any time, be loaded normally from disk or referenced from other code and executed any number of times. This post is a minimal example just to practically show the lay of the land of dynamic code generation. Background (Skip this section if you just want to quickly review my sample!) This post is also the result from feedback on my previous posts Dynamic Code Generation in...

New blog on stuff like Castle Windsor and nHibernate in ASP.NET MVC

A colleague of mine, Rikard, has entered the blogosphere! His entry on Castle Windsor and nHibernate in ASP.NET MVC commands respect at least from me! Well worth a read: http://opinionmachine.wordpress.com/ Cheers, M. Technorati Tags: blogging,ALT.NET,.NET,nHibernate,Castle Windsor,ASP.NET,MVC

Dynamic Code Generation in .NET presentation with Anders Hejlsberg and myself online at Viddler

Please enjoy a tour of what coding was like before Dynamic Code Generation, what it is like today and what it will be like tomorrow! Presented by Anders Hejlsberg and myself! I did a presentation this year at Øredev where I spoke about Dynamically Code Generation on the .NET platform. Anders Hejlsberg himlself is part of my presentation in a video that he recorded just for us at Øredev. It is the same sample of using the Compiler as a service that he did at this years PDC. Here is the original post on that sample video: Dynamically Generated...

ALT.NET Oresund

An ALT.NET Community for Oresund is created! I hinted at a project I’ve been working on when I announced that my son Elvis is born on Dec 23. Let me just briefly give my HUGE thanks to all the warm wishes my family and I got from that post – 68 wishes to date! So what’s the project? OK… hmmm… title sort of gave it away didnt’ it? Announcing the ALT.NET Community Oresund! You join at our forum: http://groups.google.com/group/oresund-altnet. Later you will be able to register as a member at our site. We are...

Getting a safe temp catalog to use in your program

How to create a temp catalog in a good way where user access permissions are concerned. Update note: I was focusing on Environment variables when I wrote this post and forgot about the other way to skin a cat (and I’m sure there are even more than two ways): using the static method on the System.IO.Path class. So now there is more than one way to do it below. Ever tried to create a temp catalog from your program like so: string temporaryDirectoryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Guid.NewGuid().ToString("N")); Well… or something similar. Get the current dir that you are executing...

Dynamically Generated Code at Øredev co-presented with Anders Hejlsberg

Here is my post of the code, the video by Anders Hejlsberg and the slides. (YES Anders Hejlsberg is doing a demo in the video attached below…) Phew! I’m through the rabbit-hole with my presentation at this year’s Øredev. It was a deep dive into generating code in the run-time. The presentation went very well. This is a very advanced topic to talk about and so I’m very happy with the furious feedback I got. Furious feedback is a system of having one red, one yellow and one green note in piles at the door and a...

FlagsAttribute how to use it right

I like flags. Rarely do I get a chance to use them. Today the perfect opportunity came up and I recalled the "good way" of dealing with flags that I had found last time. After some digging I found it and I thought it is worthy of another post in another blog. So no news today just a helpful test class that shows exactly how to define and use an enum with the FlagsAttribute. [TestClass] public class FlagsTests { [Flags] public enum Metasyntactic { Noop...

Silverlight Greeting Creator sample online

My brilliant colleagues have created a Greeting Creator that they have put up on the Silverlight.NET site. It is filed under Home > Community > Gallery > Silverlight 2 Samples > Greeting Generator Go check it out and play with it online, it's really cool! (Or download it from Codeplex and fiddle with it: Greeting Generator on Codeplex!) Cheers M. Technorati Tags: Silverlight,.NET

Performance by Design in your .NET Applications

(This .NET Performance by Design review turned out to be a summary of resources, tools and tips & tricks surrounding .NET Performance and Designing for Performance. Hope you enjoy it as much as I did writing it.) There is a lot you can do in respect to taking the correct steps to make sure you have considered performance to a big enough extent in your design of an application in .NET. What’s with the belt and suspenders mumbo-jumbo in the opening sentence here? Well. First of all; it depends. Second I don’t want to offend the YAGNI/premature optimization guys...

The future of programming languages according to Anders Hejlsberg

According to Hejlsberg the three major trends for the future of programming languages are: Declarative, Concurrent and Dynamic. Here is a brief description of these trends: Today most programming languages are imperative in nature. Declarative programming concerns itself more with the what of the programming than the how. In the talk Hejlsberg gave the great and kind of classic example using LINQ to declare what we mean for a piece of code to do rather than imperatively in standard C# code it up in a mess of code that is very hard to read for later...

Lambda Expressions - I’m in love!

Probably the most geeky title ever written! But hey – they are sooo bad ass! Seriously! Think of this post as a history lesson or nostalgic trip if you like! (Meanwhile, yes, my feed is down. Starting to regret my moving feedburner to feedburner.google. The big search company is just another company. Wonder when the public will realize? It’ll be interesting to see if I have any readers left at all once google gets their act together!) Without lambdas – the classic old school way: public class Program { public void Main(string[] args) ...

MEF is now MS-PL

Good news today 8when Microsoft shows it’s OpenSource friendly face in the form of MEF moving from the MS-LPL licence to MS-PL. In fact this was always the plan it seems but “just putting it out there” is still something that takes a little bit of time (and maneuvering with the suits no doubt)! Read more from Glenn here: MEF going MS-PL, the little engine that could. Cheers, M. Technorati Tags: .NET

MEF Contrib on CodePlex

Bill Krat started up a MEF Contrib project on CodePlex and he made me a coordinator of it too: (I am NoopMan on CodePlex) In this contribution project I uploaded my sample web Application that uses MEF: MEF Enabled Web on CodePlex. (Sample previously blogged with a lengthy explanation here: Managed Extensibility Framework (MEF) used to make a Composite Web ASP.NET Forms Application). Pretty cool to get down with these guys! Now all we need is Glenn’s announcement early next week: Update on our MEF license status Cheers, M. ...

.NET User Group Event in Malmö 25/9-08

On Thursday 25/9 it is time for a SNUG event (Skånsk .NET User Group). This time will feature a visit from the Dark Side in the form of Rickard Öberg who has been a Java developer since James Gosling wore shots. He will be presenting his latest baby. When I say latest I mean in the form of a baby that has come after Rickards creation of JBOSS. That alone makes you think that perhaps this baby might also be totally brilliant! Here's Rickards presentation of his brain child Qi4j: OOP neglects the need of...

Managed Extensibility Framework (MEF) used to make a Composite Web ASP.NET Forms Application

Phew that blog post title sure is a mouthful! (As you can see I wanted to get all the key words into the title!) So what's this post really about? I am making an ASP.NET Forms Application composable using the new Managed Extensibility Framework (MEF). By composable I mean that I have for instance a Page that hosts dynamically loaded UserControls. Page and Controls may all communicate with one another but I want to do it without having to hook them up to each other manually. Also you don't want to set compile time references between any different assemblies...

Visual Studio Open Space in Stockholm - Feedback

Today was the final stop of Dotways Visual Studio 2008 & .NET Framework 3.5 Open Space tour! It is sad that such a fun event happening tour is over. Yet it is good to know that in each event participants seemed very pleased with the outcome. Stockholm tonight was no exception. The arrangements were exquisite and the meeting venue was really good! Two Microsoft participants joined our merry bunch: Robert Folkesson and Dag König. I repeat that in Sweden Open Space is a novel thing and some aspects of the Swedish folk mentality makes it hard for us to...

Managed Existensibility Framework (MEF) is now on Codeplex

One guy who works hard at putting all of Microsoft's new products online and open is Glenn Block. Recently he's been working on the Managed Existensibility Framework (MEF). He and some other prominent blogers just announced that the MEF is now live on Codeplex: MEF on Codeplex What is MEF? (cut from the site) It is a framework that simplifies the creation of extensible applications. MEF offers discovery and composition capabilities that you can leverage to load application extensions. What problems does MEF solve? MEF presents a simple solution for the runtime...

Why the PDC is special and the things I won't miss while there

A while back I happily announced that I will be going! See you at the PDC 2008! I've also blinged my blog properly http://blog.noop.se. Now the time has come to begin building up my own expectations about PDC and to share my sentiments about this great event! But first a recap: Our company (Dotway) went 14 people to PDC 2005 and it was really cool! After my girlfriend at the time came over to California and we drove around (a big drive through San Diego, Tijuana, Rosarito (Mx), Palm Springs, Lake Havasu City, Grand Canyon, Las Vegas and back...

ReSharper 4.1 is out

ReSharper 4.1 has been released with a bunch of improvements in performance and some fixes. Here's the release notes so you can see for yourself: http://www.jetbrains.com/resharper/releaseNotes41.html I recommend an immediate upgrade! And if you don't have the product I recommend an immediate test drive: http://www.jetbrains.com/resharper/download/index.html "No license key is required for running the fully-functional edition of ReSharper v 4.1 during a 30-day evaluation period." Cheers, /Magnus Technorati Tags: Tools,.NET,ReSharper

ALT.NET Unconference in Stockholm

Word of the day: Unconference! The Swedish ALT.NET community leaders are kicking off the first official Swedish ALT.NET event! Very nice! Wish I could be there but I don't live in Stockholm. We also have an ALT.NET track at Øredev later this year featuring ALT.NET enthusiasts such as Scott Bellware, Ayende Rahien and Glenn Block. And of course the Swedish ALT.NET guy Joakim Sundén (Joakim Sundén). Cheers, /Magnus Technorati Tags: ALT.NET,.NET

Visual Studio Open Space in Linköping - Feedback

Half assedness in our software development world, LINQ, lots of tools and more! Read on! We continue to meet interested and dedicated (and interesting) technology experts wherever we take our Open Space Tour. Yesterday in Linköping was no exception to this rule. They guys at the event were a little bit hard to get to begin talking but underneath that surface there lurked a whole lot of knowledge and experience just aching to get out and to be shared. The common feeling was that it was really nice to have a setting to talk to those with a similar...

ASP.NET MVC Preview 5 is out

And there are a few new and really neat features in the latest preview (ASP.NET MVC @ CodePlex). Next release will be the official Beta according to Phil: ASP.NET CodePlex Preview 5 Released Let me just point to a few things from the release notes that caught my attention: The IViewEngine interface now has a RenderPartial method that support the concept of rendering partial views. This is used in tandem with the Html.RenderPartial helper method. The important part is that your partial view can be rendered by a different view engine than the containing view. Say you have...

Dynamic Data on regular ASP.NET pages

Dynamic Data is only for crazy auto generated sites where you expose too much functionality and allow stupid unskilled programmers to do stuff they shouldn't! Well... I've heard this objection a few times now and I recognize that this is a very valid concern. However there are a few more things, very useful things, that you can do with Dynamic Data! (Dynamic Data shipped with .NET Framework 3.5, SP1) You should not add a data context to your site with all tables and register this model with ScaffoldAllTables = true! That would be a bad thing to put into...

Visual Studio Open Space in Gothenburg - Feedback

Our Visual Studio and .NET Framework 3.5 Open Space event in Gothenburg turned out quite different compared to our Malmo event on Monday (Visual Studio Open Space in Malmo - Feedback). I think the key difference was that we were a few more participants and so could form more than one discussion group. An Open Space is typically organized (not so much but still) around some main topic but discussions branch out in many smaller groups where people flow from one group to the next and topics vary over the course of the happening. We branched out to many different...

Enterprise Library Policy Injection Block supports Composite Oriented Programming

My last post Composite Oriented Programming spike on Unity Application Block turned out rather lengthy. Yet I forgot to embellish one thing: I don't only use the Unity Application Block to make it work. I also use a couple of methods from the Policy Injection Application Block which is one of the Application Blocks in Enterprise Library. It's not a lot I use. Actually I used it more as a roadmap in my spike than anything else. Yet I felt that it was better to copy some behavior from the PI block rather than implementing the same things in...

Composite Oriented Programming spike on Unity Application Block

Suddenly the coolness of Qi4j starts seeping into the .NET community. There are now several proofs of concept available. And here is one more. There are two major differences with this post compared to the other ones out there: This spike does not rest upon the obvious and very suitable Castle project. This implementation uses another DI framework which I've learn to use and really like. It is not as evolved for sure but neither is it HUGE and complex. I used the Unity Application Block from Patterns & Practices. I...

Microsoft Gold Sponsors Øredev 2008

This just in: Microsoft Gold Sponsors Øredev 2008! Wohooo! We the organizing founders of Øredev, particularly Dotway and the Øredev program committee are proud, happy and try to appear humble on this VERY great day!   I don't know if you understand how great grand super HUGE this is for us! Cheers, /Magnus Technorati Tags: Øredev,.NET,Microsoft

Visual Studio Open Space in Malmo - Feedback

Technorati Tags: .NET,AJAX,Agile,ASP.NET,MVC,Tools Our Visual Studio and .NET Framework 3.5 Open Space event in Malmo was a success! It did draw a small crowd this first time but those who came were very happy with the outcome and based on initial feedback they want this to reappear another time! I can only agree on the positive sentiments and add how interesting it is to share knowledge (like we do at Øredev) and learn what challenges colleagues in the community have. The evening turned out to become a veritable link feast where everybody wanted to know tips n tricks...