UPDATE: Added the presentation to download below.
I found through a blog post of Greg Duncan a site (Research channel) that has a video of 3 hours on how to design class libraries in .net.
“Produced: January 22, 2007
Description:
This class presents best practices for designing frameworks that are reusable
object-oriented libraries. The guidelines are applicable to frameworks
ranging in size and in their scale of reuse from large system
frameworks to small components shared among several applications. They
started as a small set of naming and design conventions, but have been
enhanced, scrutinized, and refined to a point where they are generally
considered the canonical way to design frameworks at Microsoft. They
carry the experience and cumulative wisdom of thousands of developer
hours, over three versions of the .NET Framework.
Speaker(s):
Krzysztof Cwalina, program manager, .NET Framework Team, Microsoft
Runtime:03:40:56″ [Description leached in full]
Sadly enough I didn’t see any possibility to download the video so I could watch on the train on my way home…
Download here: http://suddenelfilio.net/cwalina/14050.asf [461 MB] (I hope I’m not braeaking any copyright rules)
Source: The ResearchChannel – http://www.researchchannel.org/prog/displayevent.aspx?rID=11087&fID=2740
Filed under: .net, .net 2.0
March 23, 2007 • 10:39 am
The ajax control toolkit contains a control called ModalPopupExtender. This extender allows you to create a dialog-like interface for webpages.When you use it like it is meant to use you would set a TargetControlID and a PopupControlID. The first is the control that will trigger the popup to show while the latter is the control that will be shown. That’s already nice, but what I needed recently was to show the result of a certain query in such a popup. This means that when I click the control that is pointed as TargetControl it would do a postback, execute some serverside code and then show that result in the browser. This is logical you might think but the problem is that when you click the control assigned to the extender as TargetControl you’ll see the popup immediately and only then the postback occurs.Okay how to solve this? Well add an additional linkbutton for example and make sure it is visible but has not text. You can then set the TargetControlID to this “no-text” linkbutton. Since there is no text, you can’t see it and since you can’t see it the user won’t click it. Nifty
Next you can have a second linkbutton the performs a callback to the server and executes some serverside code. If you put this linklabel in an asp.net ajax updatepanel you won’t notice the callback and you can use the ProgressIndicator functionality in asp.net ajax.At serverside you can perform some code execution and for example set a Label’s text proeprty to the result. Finally you can access the ModalPopupExtender and call the Show method that’s available this will cause the popup to appear.I really like this way of working because it allows for a nice userinterface experience and interaction with user.
*** UPDATE: I am sorry for all of you that wanted the sample code, with moving to this blog I lost it when my old blog went offline. I cannot provide you with the code anymore ***
Filed under: .net 2.0, Asp.net 2.0
Today I had to work with some usercontrols in our project. The problem was that we do some database access from within the constructor. For all this to work well everything needs to be in the right place and configured correctly which is not the case in design mode. So when I tried to open a user control at design time I got various errors because there were exceptions accessing the database and so on… You get the point.
I wanted to solve this by adding the if Not Me.DesignMode then statement so the database code would not be called at design time. I started replacing all the code in the user controls only to discover that it doesn’t work.
What was the problem? Well it seems that when you have a user control the DesignMode property is not reliable. First off all its always false in a constructor or any code called from within the constructor. The false or true value for the DesignMode property is set when the control is sited (ISite interface) the only problem is that this happens after construction.
An other problem is nested controls. When you have a user control in an other user control or form and you debug it at design time the nested control will always indicate that it is not in DesignMode. Pretty annoying,no?
After some searching on the web and having viewed multiple solutions I found a solution that will solve in my case both problems mentioned above.
It has nothing to do with the control or it’s DesignMode property. I found that in the namespace System.ComponentModel there is a class called LicenseManager that has a property UsageMode. This property has got 2 possible values Runtime and Designtime. You can use this instead of the DesignMode property to check if you are running in design or at runtime because it will return you the correct state already in constructor code. An other advantage is that it can be used in nested user controls because it is not dependent on the control to set the correct value this way you can also use it correctly there.
Nice isn’t it? For me it does the trick, it might be still possible that there are some issues with this way of working, but I haven’t experienced any problems yet…

Filed under: .net 2.0, Visual Studio .Net 2005
March 20, 2007 • 11:39 pm
When I was working on the ISBNDB API wrapper website I faced the problem of having grey backgrounds on my png images that were supposed to be transparant. After searching for a bit on the all knowing google I found the following site that proposes a working fix in the form of a javascript.
URL: http://homepage.ntlworld.com/bobosola/index.htm

Filed under: Asp.net 2.0, IE
Hello,
I’ve been working on and off on the isbndb api wrapper. It’s a managed component that wraps around the api of isbndb.com.
I’ve created a small website that will demonstrate the functionalities of the wrapper. It is still very basic and there are already more functionalities completed that can not be tested on the website yet.
Here is the site: http://suddenelfilio.net/isbn/

Filed under: .net 2.0, Asp.net 2.0, isbndb
Due to recent postings I would like to take your attention to this blog’s disclaimer.
You can find it by clicking on the about link on top of the page. Anyways here it is once more:
Disclaimer Suddenelfilio ’s Blog
The information in this weblog is provided “AS IS” with no warranties, and confers no rights.
This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.
Feel free to challenge me, disagree
with me, or tell me I’m completely nuts in the comments section of each
blog entry, but I reserve the right to delete any comment for any
reason whatsoever (abusive, profane, rude, or annonymous comments) – so
keep it polite, please.

Filed under: Blog, General
March 15, 2007 • 10:56 am
I’m currently studying for my next microsoft exam (70-529) that gets you certified for distributed development. I was reading in the training guide when someone asked me what the use was of the OneWay attribute.
So I explained to him that you can mark a web method with the OneWay attribute which indicates that this method can be called without the need to wait for a result. It’s the “Fire & Forget” principle. Sort of like the americans do in Iraq
So his first reaction was that it sounded the same like calling a procedure (sub in vb.net or void in C#) without it returning a result. Well yes and no. Yes because it has the same effect and no is in the difference that when you do a synchronous call to a web method that is a procedure the client will still wait for the acknowledgement of the webserver. So you make the call while the code on the server executes the client waits and when the code is finished the client is notified. While when you call a OneWay decorated method this doesn’t happen. The client just launches the call and continues working, it doesn’t wait for anything. So if your code takes a long time to execute in procedure the client will need to wait that long which it does not need to do with a OneWay method.
Okay this was clear, but he had another remark that was: “Why not mark all your procedures with OneWay as apparently it improves performance for the client ?”
Well that depends wether you want your client to be aware of certain exceptions that might occur on the server when the code there is executed. If you want this then you can’t use the OneWay method because of it’s nature the exception will never reach the client. You can test by just throwing any exception in the server code and decorating the erroneous method with the OneWay attribute. Then you call that method and you will see the nothing happens. The client just continues processing.
I already anticipated his next question that would be: “Is there an intermediate alternative than that I can use ?”. Well yes actually there is. Asynchronous method invocation.
There are several ways you can invoke web methods asynchronous:
- Create a new thread and execute the code synchronous on the separate thread.
- Create a new delegate with the same signature, instantiate it and then use the BeginInvoke and EndInvoke methods in collaboration with the IASyncResult interface.
- Just add a web reference to your project in vs.net and the asynchronous methods will be created for you.
If we take the last option you’ll see that when there is a synchronous method called “GetStockQuote” you can find the asynchronous counterpart as “GetStockQuouteAsync”. Calling this last method will execute the method asynchronously and you can continue processing other things. When you need to process a result you can attach to the Complete handler of the asynchronous method and in there process any results. This will only work of course when your method you are calling is a function. Also the important part is that when there is an exception it will be returned to the client.
These are certainly not all the possible solutions to work asynchronous but it demonstrates that you can simulate the effect of a OneWay method with the advantage of noticing any exceptions on the server.

Filed under: .net 2.0, Web Services
March 13, 2007 • 12:46 pm
Today I arranged that I would go to my company to set up some software in the evening. We have got a server there that we used to run some test vm’s on. On this server there was a paper taped to it stating that nobady should shutdown or disconnect the server. I’ve been gone for only 2 weeks on a mission now only to find out that the server had been replaced. Okay I was already pissed about that because I explicitly asked not to turn of the machine. They moved it after a power outage but not only did they move it to a location where there is no working network available. They even managed to connect the useless networking cable to the wrong interface.
You can say well is that so bad? Well yes actually this proves that they just were lazy and moved it alltogether plugged in some wires and pressed the powerbutton hoping that everything would be okay. It’s my opnion that when you want to do something that has been explicitly prohibited you could at least ask the person who knows about these things before doing something stupid.
Even if they succeeded in plugging the network cable in the correct interface the machine still was useless because it needs to have certain things restarted for it to have any use.
Anyways I really was disappointed in the lack respect for other people’s work, you just don’t do something like that.

Filed under: General