Category Archives: dotNET

Must read post by Sam Gentile – Distributed computing is your friend

In this essay which questions why it seems people are not leveraging .NET to do real scalable enterprise apps, Sam reinforces a point that he has made often and states again in his comments on this post . Too many developers pick up Visual Studio.NET and kind of start where they left off, without looking to see what’s new in there. They get stuck on the IDE improvements or the server controls and don’t look deeper to the stuff that lets you build really awesome applications. Even if you are like me and not in a situation where you are building huge apps, you can still use your smaller apps as a playground for learning how to use these things and STILL realize a great benefit, not only to your skills and understanding of .net, but the applications will benefit. Sam seems to be mourning the fact that people are once again writing client/server apps because this is what the IDE wizards create and also that there are too many samples out there that demonstrate code without middle tiers. Joel Semeniuk talked about this exact same problem this morningin Trivial Samples? How about Patterns? 

I am not writing gigantic enterprise apps, yet everything I write for my clients, I write with some type of scalabilty in mind. I have one client that has gone from 15 to 100+ employees in the last 6 years and I think in another 5 they will have operations around the country. Everything that I write for them now, I try to build with that in mind. Even though I fear it will all be legacy code by then… Sometimes I know that what I am doing is overkill. Often I even don’t charge them for some of the extra work I do on their apps that is possibly more for the sake of my education. Reading what Sam says definitely reinforces my justification for this.

Sam and I think very differently and work differently (if he’s reading this, he probably just spit out his coffee). He writes big, I write small. I often get something different out of what he is writing than what his main point is (which tends to make him nutty – especially when I then go write about it in public…). But even I have slowly evolved my own methods as I have gotten deeper into .NET. In the past, yes, I too started out by seeing what’s new in the IDE. I have, in the last 2 years though, learned a LOT about .NET and am working with a lot of pieces of this that always seem terribly daunting at first. BUt I know that by learning them and using them I am taking advantage of what .NET is all about.

Sam knows .NET from the bottom up, not the top down (in my mind) – take heed of his message. It was Sam that inspired me to really want to more than a developer using .NET but to be a .NET developer.

Raising events from dynamic forms through reflection

I have been using reflection for a while to open up forms dynamically and have been past the form properties and form methods hurdle for quite some time. I just had to raise an event from my form that is being loaded dynamically. A quick article by Dino Esposito on VB2theMax made it relatively easy to add this little bit of functionality into my .net quiver. Since I am doing it a bit differently (using a form, rather than a class) here is how I did it. This isn’t my exact code, since I have stripped out some other trickery that I don’t want to get in the way of what I am trying to show here.

Dim asmAssemblyContainingForm As [Assembly] = [Assembly].LoadFrom(“AssemblyContainingForm.DLL“)

Dim TypeToLoad As Type = asmAssemblyContainingForm.GetType(“assemblynamespace.formclassName”)

Dim GenericInstance As Object

GenericInstance = Activator.CreateInstance(TypeToLoad)

Dim f As Form = CType(GenericInstance, Form)

‘//here is the event setup

Dim frmEventUpdateTree As System.Reflection.EventInfo

‘//“TreeSourceChanged“ is the name of the event being raised from my form

frmEventUpdateTree = TypeToLoad.GetEvent(“TreeSourceChanged”)

‘//create a delegate of the same type as my raised event to a local method  named “SetGetNewTreeTrue“

Dim frmDel As [Delegate] = [Delegate].CreateDelegate(frmEventUpdateTree.EventHandlerType, Me, “SetGetNewTreeTrue”)

‘//link up my delegate to the dynamic form

frmEventUpdateTree.AddEventHandler(f, frmDel)

More on BCL literal definition

Sam Gentile did a presentation at VTdotNET in September that really took the time and care to explain the many terms that define the .NET programming that we do. Although one of the very minor points of his talk, in there he happens to clarify the BCL vs. FCL, which I talked about in this post and discussed a bit with Ian Griffiths from Developmentor (in the comments) as well as Kit George from the BCL Team at MS via email. There really is a lot of misinformation and confusion about these definitions which don’t really impact too many people, but I just somehow got curious.

Here are just some basics that may be totally redundant to some, but may have never been really clear to others.

BCL=Base Class Libraries which are part of the ECMA specification for Common Language Infrastructure (CLI). The CLR is Microsoft’s an implementation of that. Rotor and Mono are other examples of implementations.

In .NET, Microsoft has taken the BCL and added to it all kinds of goodies like WinForms, Data, etc. This is called the FCL (Framework Class Library).

Really – how many gazillions of times have you seen this already?

I am going on and on about this because I have heard many people say “the BCL is ALL of the classes in .NET“.

I even happen to have a copy of Addison Wesley’s Common Language Infrastructure Annotated Standards, but the real definition of the specs is downloadable from the ECMA site (above) if you are curious. I actually have done so, but must now stop the insanity and get back to the programming work I have to do this afternoon!

If you care to understand any of it – where the class libraries come from, what people mean when they say BCL, BCI, ECMA etc etc, I highly recommend checking out Sam’s deck (this page and find the sept 2003 presentation) or even requesting him to come to your (U.S. or Canadian) User Group via INETA. If you view the powerpoints, be sure to turn on your speakers. (heh)

DevDays – speaker training and last day of discount!

Steve Smith and I had to miss the DevDays (web track) speaker training last night because of the Vermont .NET User group meeting. But I know we will have plenty of opportunity to make that up.

Today is the last day for the DevDays discount. If you wait until tomorrow, you will have to spend $24 dollars MORE (well it is an additional 33%…) to attend the day and get not only lots of great training but WHIDBEY bits!!!!! (and more) My point is really the whole days is so damned cheap to attend – $75 with the discount and still only $99 without.

The user group meeting was awesome – Steve is a phenomenal presenter – I learned a ton. But I have to write more about that later.

Crystal Reports Workaround

There is a barely documented problem with Crystal Reports for .NET that occurs if you try to pass a dataview as a datasource to a report. The report has been built via a project dataset (XSD).

Here is the tech support entry. It has a tracking id of “CR ADAPT00117088”. I probably don’t have the latest patch but there is no reference anywhere else to this track id.

The work around is just to pull the dataview data into a new datatable. Crystal doesn’t give a sample so here is one for anyone who may be looking.

First here is the long way around if you need a table to move into a dataset.

Dim tbl As DataTable = myDataView.Table.Clone
Dim iRow As Int32
For iRow = 0 To dv.Count – 1
   
tbl.ImportRow(dv.Item(iRow).Row)
Next
mycrystalreport.SetDataSource(tbl)  ‘this assumes you only have one table for your datasource

(I need to make a confession – I have been so stung by the problem of trying to move a table from one dataset into another that I didn’t stop and think that I was sending a datatable not a dataset, so I did this the long way around. Thanks to Mike below for pointing out my silliness…see his comment for the easy way.)

Conference evals from PASS

Interesting post from 2003 PASS track chair, Roman Rehak, on the evals from the conference. Besides been a .NET developer, Roman is an absolute whiz with SQL Server and has been doing a lot of talks for developers on what they should really know about working with SQL Server. Keep an eye on his weblog for some great pointers and insights – and occasional recipes. He happens to be an awesome cook – I have been fortunate to partake in some of his wonderful meals.