To Invoke or not to Invoke? That is the Question!

Yesterday I was having a problem with my UI on my smart client application.  I’m using the offline data block from the MS Patterns and Practices group.  It took awhile to learn how to use this, but now that I am I really like it.  It uses a separate thread to do the data requests.  Well, as most applications would I wanted that thread to update a progress bar on my UI to tell the user how many requests where in the queue and when they where completed.

This sounds like it should be easy, but hopefully most of you know that a separate thread cannot update a UI element on the main GUI thread.  This article talks about why and how to do it using the Invoke() method.  I was using the Invoke() method and everything was running fine at first.  However, after I started testing the application started to deadlock\freeze.  I put lock statements all around my code to try and avoid the problem to no avail.

Finally I ran across this post from Kristof Verbiest which explained my problem.  The Invoke() method IS NOT an asynchronous call.  The code will wait for the method called within the Invoke() to complete before it moves on.  So, what was happening was my main thread was waiting for the Invoke() and also calling the thread to do another request.  This caused the deadlock.  The post from Kristof explained that the BeginInvoke() method IS an asynchronous and will allow the code to continue.  By changing my Invoke() calls to BeginInvoke() I fixed my problem.  Thanks Kristof!

So the answer is to not Invoke(), but to BeginInvoke()…

Posted in | 2 comments

Application UI Design Mistakes

I came across this article in my daily web surfing.  I’d like to think I know all these rules, but they are good to keep in the back of your head and revisit when you start desigining UI for a new project.

Posted in | 0 comments

South Colorado Launch 2008

It’s official!  Friday, April 4th from 2:00 – 6:00 PM all three South Colorado User Groups (.Net, SQL Server and Windows Server) will be collaborating to bring you some great content related to the new releases of Microsoft technologies.  All the sessions are still being finalized and the official schedule should be up soon.  Keep your eye on the official site here for more details.

I’m sure there will be great content, but please plan on attending for no other reason than to connect with the Microsoft community here in the South Colorado area.  Learning from our peers is a fun way to think outside the box and come up with new ideas to solve everyday issues.  I hope to see you there.

If the weather cooperates you should just take the whole day off and get in 18 holes before attending.

Posted in | 0 comments

WCF 404 Page Not Found

Just a quick note about hosting your WCF service in IIS.  I had some problems getting this to work yesterday.  Everything worked great on my developement machine.  I had my WCF service serving up data and functionality to my ASP.Net front end and a Windows Service I’m using for automation and monitoring.  I moved everything out to IIS on the test machine, configured the sites in IIS and started testing.  I kept getting HTTP 404 Page Not Found Errors while trying to reach my WCF service.  I found a great blog post from Jean-Paul Smit that finally solved my issue.  I had to do number 3 in his list of possible solutions. 

%windir%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe /s:W3SVC

Once I ran this from the cmd prompt everything worked great.  Thanks Jean-Paul!

One final note: If you don’t have the file mentioned above you need to download and install .Net Framework 3.0.  I ran accross this on one of my servers. 

Posted in | 12 comments

Serializing a Generic Dictionary

So, I created all this fantastic code (God, I love my work) that used a singleton to hold some data that I needed throughout my app.  One of the properties in that class was a generic dictionary.  Well, as I got further into the application I came across the need to persist this data to an XML file.  Naturally (almost instinctively, which means I have no life), I wrote the few lines of code to use the XMLSerlializer to save this to disk.  The problem is the generic dictionary is not serializable.  I was dreading the idea of changing the way I was storing and using that dictionary all through out my app.

To make a long story short, (too late) I did a search and found this post from Paul Welter’s blog.  All I needed to do was create this class in my project, change the data type on my dictionary in my Singleton and it all worked and serialized perfectly.  Thanks Paul!

Posted in | 0 comments

Salesforce.com Announces Development-as-a-Service

Many of the ‘line of business’ applications today are starting to expose their core framework as a development platform.  MS CRM is a great example of this.  It’s a great CRM solution, but it can also be extended and used to solve countless other line of business needs.  For more information on MS CRM check out David Yack’s CRM blog or the MS CRM site.

Salesforce.com is jumping on this bandwagon but is also adding an interesting twist.  They are selling their development framework as a service.  It’s also interesting that they are introducing a $0.99 per login option.  You can find some details about this announcement here and get more information on the Salesforce site.  MS CRM has a similar option called MS CRM Live that includes a subset of the extensibility features and is hosted by Microsoft.  You can read more about MS CRM deployment options here.

Looks like these two products are going to battle it out in this space.

Posted in | 0 comments

LINQ Visualizer

Scott Guthrie does a great job of describing how to get and install this here.  Take the 5 minutes to do it.  It’s worth it.

Posted in | 3 comments

LINQ Talk - Colorado Springs SQL Server User Group

I just got the opportunity to do a talk on LINQ at the Colorado Springs SQL Server User Group tomorrow night January 16th.  The meeting starts at 5:30.  I’m going to add some content that is more SQL Server related and try to inform everyone what LINQ means to the SQL DBA community.

For more info please vist the Colorado Springs SQL Server User Group site.

Hope to see you there.

Posted in | 0 comments

Accessing the ApplicationSettings section of the App.config with C#

OK, this sounds like a no brainer, but I ran into an issue the other day and it took me forever to find the information needed.  I used the GUI in VS 2008 to create some strongly typed application settings.  This is easy to do.  Right click on the project and select Properties.

AppSet1

I created two settings: one is a DateTime and the other is a bool.  This is the easy part.  The hard part is getting and saving these settings in code.  Well, it’s not hard once you know what you are looking for.  I searched far and wide using ‘Application Settings’ and C#.  I found all kinds of document ion about the Mysettings namespace in VB.Net but nothing on C#.  I even scoured the documentation from MSDN.  I finally found an answer on a forum somewhere.  You use the ‘Properties.Settings.Default’ namespace.  So, I can access my settings using this code.

AppSet2

If nothing else just remember this post for future reference in case you run across this yourself.  For some reason the ‘Properties’ namespace just isn’t intuitive to me.  There is also a lot of confusion out there revolving around the difference between ‘Properties.Settings.Default’ and the ‘System.Configuration.AppSettingsSection’ namespaces. One of the reason I’m blogging on it is so I can reference it the next time I run into this.

Posted in | 18 comments

Microsoft's Enterprise Library

I recently received a questions regarding the best practices for doing data access.  My company has our own internal data access architecture and code generator that works great.  However, if you are starting a new project and don’t have an established architecture, I would take a serious look at Microsoft’s Enterprise Library as a starting point.  It contains many best practices regarding data access, logging, exception handling and more.  What’s better is you get the source code so you can tweak it as needed.  

There is also some great and affordable training on Enterprise Library available from Innerworkings.  I’ve blogged about Innerworkings before (here).  They have mastered e-learning.  Just go to the catalog on their site and you can find the Enterprise Library training in either VB.Net or C#.  I think the two part series will run you about $60.  Not a bad way to get a quick start in this stuff.

Posted in | 3 comments

JavaScript Performance

I subscribe to the Jeff Atwood’s Coding Horror blog and he posted this yesterday about JavaScript performance.  He also mentions that the browser market is getting more and more competitive so if you have a public facing web application make sure it looks good on all the latest browsers.  Sometimes us ASP.Net coders forget there are other browsers out there  

 

Posted in | 0 comments

ASP.Net 3.5 Extensions and ASP.Net Dynamic Data Support

I also installed the ASP.Net 3.5 Extensions yesterday.  I figured I might as well take the plunge on all this stuff.  I’m hoping to install and play with the ADO.Net Sync Framework sometime soon as well.  Anyway, the CTP for ASP.Net Extensions is an easy install.

The best source for information on this is Scott Guthrie’s blog.  If you don’t subscribe to his blog you should.  He post great stuff for developers of all skill levels.  Below are a couple of cool posts he’s done lately related to the Extensions CTP.

What’s Included in the ASP.Net 3.5 Extensions CTP

ASP.Net Dynamic Data Support

Posted in | 0 comments

Installing the Latest Version of the ADO.NET Entity Framework

Last night at the Installfest in Denver we got a quick look at the ADO.Net Entity Framework.  It looked interesting to me so I researched it a bit more today.  The overview here is a pretty good place to start.  I’d read through that first to get an idea of what we are trying to accomplish.  Then make sure you have Visual Studio 2008 installed and follow these steps to install the add-ons that allow you to start playing with the Entity Framework:

  1. Make sure you uninstall any previous versions of the ADO.Net Entity Framework.
  2. Install this hot fix for Visual studio 2008.  Honestly, I could not find much documentation on why this is needed.  For what it’s worth, I installed it and it didn’t break anything that I can see.
  3. Install the ADO.Net Entity Framework Beta 3.
  4. Install the ADO.Net Entity Framework Tools.
  5. Install the ADO.Net Entity Framework Samples.
  6. Check out this additional documentation.

If you were using the old version of the framework you might want ot check out this post about the breaking changes between Beta 2 and 3.

Other than that happy coding!  Please let me know how it goes and any cool things you find with this stuff.

Posted in | 0 comments

Visual Studio 2008 Installfest

Last night we had a great event in Denver.  It was called an ‘Installfest’ and included a free version of VS 2008, free drinks, great food, networking and great demos of the new features in VS 2008.

If you’d like to take a look at some of the stuff we discussed here is a link to Rob Bagby’s post with the info.

We also talked about many things that are not in these demos.  We spent some serious time on LINQ.  If you want to learn more about link you can get started by downloading my presentation and demos here.  Scott Guthrie’s blog also has a whole series on LINQ.

Finally, we touched on a couple of new things that look really cool.  The Entity Framework and the Sync Framework.  I did a bit more research on these two topics today.  I also installed all the extensions and add-ons to get these things working.  I will put the installation steps in a different post shortly so those folks looking just for the steps can find them.

Overall, it was a great event and I recommend going to an Installfest in your area.

Posted in | 0 comments

Software Developers Lifecycle

I’m a fan of Jeff Atwoods Coding Horror blog.  He does not just blog about technology, he also includes good information about the best practices and overall philosophies of being a software developer.  A great example is this post about the two types of programmers in the world.  If you didn’t read it please take a few minutes to read through it before continuing on.

I’d like to think that I’m in that top 20%, but in reality I’m probably in the top 20% of the 80% group Jeff describes.  I love coding, but I also enjoy many other things like spending time with family and friends.  Being the father of two children under the age of 5 (and another expected soon) when I get home it’s time to be a dad not a coder.  I also enjoy watching sports (This is my reality TV), playing sport, playing video games and generally getting out and enjoying life.  So, I rarely code on the weekend for fun.  I do it every now and then just to keep up with the latest and greatest .Net releases but it’s few and far between.

Right now your probably thinking who cares?  The reason I mention all this is that I believe just like the phases of the software development lifecycle, we as software developers also go through a ‘lifecycle’.  When I was fresh out of college I was all about the latest and greatest technology and spend much of my free time coding and researching.  I even took a weekend crash course in .Net 1.0 beta that took up my every weekend for 2 months.  It was fun.  At this point I was in the top 20%. 

However, once I got a family my free time diminished and I took a corporate job that allowed me to put in my 40 hrs a week and go home to my family.  At this point I fell into the 80% range.  Not that there is anything wrong with that. That is where I was at in the Software Developer Lifecycle.

Now, my kids are getting a bit a older and I’ve gotten back into the realm of consulting which gives me more flexible hours to ‘play’ with technology.  I’m trying to get back into the top 20%.

The moral of this post is depending on your life priorities you might have to change your perspective on the kind of developer you are.  Just like in the Software Development Lifecycle, you might have to drop into maintenance mode for awhile.  Then once your priorities change, you can add new features to your career or start back over at requirement gathering…

Posted in | 0 comments

Float DBParam to a Money column

I ran into a very interesting issue today.  I was passing in 0.0100 as a parameter to an SP.  When I ran it through debug it did not bring back any records.  However, when I called the exact same SP with the exact same params from SQL Server management Studio it worked fine.  I fixed it by adding a specific cast to my SP in SQL.  The Example is below:

where ShippingCostApplied = Cast(@ShipRateByCube as Money)

I think it might have something to do with the type conversion from .Net into SQL.  There is not a money data type in C# that I know of.  So, I was storing the data in code as a float.  Not sure why the float was not getting converted right, but keep this in mind when messing with the money data type.

Posted in | 3 comments

LINQ Slides and Demos

I’d like to thank everyone who attended my LINQ talk at the South Colorado .Net Users Group on Tuesday.  I thought it was a good discussion.  I’m still finding my way around LINQ myself and your questions and comments will help me become a LINQ master..

Below are the zip files from the meeting.  One is the presentation in both Office 2003 and 2007 format.  The other is all the demos.  You will need Visual Studio 2008 Beta 2.  You will also need to download and install the Entity Framework.  Enjoy!

I will do some research to answer some of the questions we could not answer and post my results.

File Attachment: LINQ Presentation.zip (1685 KB)

File Attachment: LINQ Demos.zip (1745 KB)

Posted in | 0 comments

Visual Studio 2008 Releases by the End Of The Month

Tim Heuer the .Net Evangelist out of Phoenix just spilled the news.  Read about it here.  I’m excited to start using it.  I’ve been using the betas off and on for about 2 months now and I really like it.

I’m also doing all my LINQ demos with the Beta 2 version tomorrow night at the South Colorado .Net User Group.  Stop by if you want a preview of LINQ or a quick look at Visual Studio 2008 in action. 

Posted in | 0 comments

LINQ talk at the South Colorado .Net User Group on Tuesday

Sorry for the recent draught of post out here, but I’ve busy preparing a talk I’m giving on Tuesday Nov. 6th at the South Colorado .Net User Group.  The group meets in Colorado Springs.  My talk is on LINQ (Language Integrated Query).  I’ve been doing research and creating samples and demos so I’ve had no time to post.  However, once I complete the talk I should have some time to blog about my LINQ discoveries as well as some CRM stuff I’m been hearing about.  Until then, I hope to see you all at the user group meeting.

Posted in | 2 comments

More On The ASP.NET MVC Framework

Here is Scott Hanselman’s take on it.

Posted in | 0 comments