Visual Studio 2012 Review

Well, today is the day that Microsoft launched Visual Studio 2012 and Windows 8 for MSDN subscribers. I’m not one to get it the day it comes out, but after all I read (mostly negative) about Visual Studio 2012, I had to download and install it.

The first comment I have to say is, “Holy Crap…how freakin UGLY can we get here!” The program icon is a bland purple sharped edge bowtie and the installation progress screen left me kind of demotivated. Ok, so its installed (on a VM of course). I open VS2012 and all of a sudden I FEEL LIKE I AM BEING YELLED AT! WHY THE HELL ARE ALL THE MENUS IN CAPS? I CAN HEAR YOU JUST FINE, STOP YOUR FREAKING YELLING!



The thing is, it is just the top level menus. The menu items are in normal casing. Was it really that much effort to make it consistent? I really hate programs that aren’t consistent since I write them for a living.

So, File-New Project-Web Application. All of the files and folder in the Solution Explorer are the same color – dark grey and make it very hard to tell what type of file is what at a quick glance.




At least the coding window looks somewhat the same. Anyway, I’m just depressed at looking at the new UI for Visual Studio 2012 and have no desire to do any creative work anymore. I will be sticking with Visual Studio 2010 for a while. I know that this is new and all but this is completely terrible. I need less stress in my day and a neat appearance with nice colors and smooth edges helps take off MY edge during the day.

Visual Studio 2012 Appearance = F

Posted in Software | Leave a comment

SQL Source Control – Easter Egg

So, while I was working today in SQL Server, I needed to get the version of my SQL Source Control (by Red Gate) and I left the About screen up long enough to allow me to play Asteriods!

Posted in Software | Leave a comment

Enterprise Library 5.0 – How to use the Data Access Application Block

I have been using the Enterprise Library from Microsoft’s Patterns and Practices even before it was officially named in 2006 (version 2.0). I use it in all of my .NET applications including windows, web and web services. It still amazes me that companies and developers have not adopted the use of something that is so simple to use instead of writing your own custom data access provider. The following is going to show you how to use the latest Enterprise Library 5.0 which you can read more about here. The Enterprise Library comes with several other application blocks but this post will only focus on the Data Access application block. This will also assume you have a stored procedure created in your SQL Server or Oracle database – Yes, this code will work for both SQL Server AND Oracle without changing anything except your connection string in the web.config file. How cool is that?

Download and Installation
The first thing you need to do is download and install the Enterprise Library in order to get the .dll files needed for the data application block. As of EntLib 5.0, you will need 5 .dll files:

  • Microsoft.Practices.EnterpriseLibrary.Common.dll
  • Microsoft.Practices.EnterpriseLibrary.Data.dll
  • Microsoft.Practices.ServiceLocation.dll
  • Microsoft.Practices.Unity.dll
  • Microsoft.Practices.Unity.Interception.dll

Once installed you can find these files in the C:\Program Files (x86)\Microsoft Enterprise Library 5.0\Bin folder if you used the default installation options.

Referencing the Enterprise Library assemblies
Let’s assume you are working on an ASP.NET web applicaiton. I typically create a folder in my project that contains all of the third party libraries and then copy the .dll files that I need to that folder. Instead of referencing the location of the installed dll files, I reference the files that are in my folder. This allows for easy maintenance of third party libraries as well as now I don’t need to have the EntLib installed on other machines. You can use this structure in windows applications as well.

Code Setup
Ok, so we have added the references to our web application and we are ready to create the database connection and do some coding. With EntLib 5.0, there is nothing you have to add to the web.config to make this work for the data application block. The only thing you need to have is a ConnectionString section properly configured to connect to your database. Let’s use the default connection string name of LocalSqlServer in the web.config.

We need to create a Database object that we will use as our connection. I typically have a public common class that I put this in. So, I’m going to add a using statement and then add a public static variable for my connection.

// Add this to the using statements
using Microsoft.Practices.EnterpriseLibrary.Data;

public class _Common
{
    public static Database dbConn = DatabaseFactory.CreateDatabase("LocalSqlServer");
}

Next, let’s code a function in the business logic layer that uses the connection, adds some parameters, and calls the stored procedure and returns a dataset with the results.

using System;
using System.Data;
using System.Data.Common;
using System.Web;

    public class _Event
    {
        #region Variables
        private string _EventName;
        private string _EventDesc;
        #endregion

        #region Properties
        public int EventId { get; set; }
        public string EventName
        {
            get { return _EventName; }
            set { _EventName = value.Trim(); }
        }
        public string EventDesc
        {
            get { return _EventDesc; }
            set { _EventDesc = value.Trim(); }
        }
        public bool bCompleted { get; set; }
        #endregion

        #region Methods
        ///
        /// Selects all events.
        ///
        public bool SelectEvents(ref DataSet objDS)
        {
            try
            {
                DbCommand cmd = _Common.dbConn.GetStoredProcCommand("usp_Event_Sel");
                _Common.dbConn.AddInParameter(cmd, "bIncludeCompleted", DbType.Boolean, bCompleted);
                objDS = _Common.dbConn.ExecuteDataSet(cmd);
                return true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        #endregion
    }

As you can see, I have created a method called SelectEvents that takes a DataSet as a parameter. This will be the dataset that gets populated. The method returns a bool indicating success or failure of the method. The name of the stored procedure I am calling is usp_Event_Sel. You will also see that I have used a parameter called bIncludeCompleted. This is the parameter that the stored procedure accepts. Then, I call ExecuteDataSet on my database connection dbConn, pass in the DbCommand object cmd and assign the result to my passed in DataSet.

A few last notes. By using the try-catch block, you will return any error messages that the stored procedure throws. The nice thing about this is that any Raiserror functions will return that message and you can display it to the user. Sometimes you have to do database checks before you execute an INSERT or UPDATE in a stored procedure and you can return any problems with these checks through the raiserror function to let your user know what is happening.

You can also add output parameters by calling the AddOutParameter function in the same way as the AddInParameter. Likewise, you can simply call ExecuteNonQuery or ExecuteDataReader if you need that functionality.

Posted in .NET | 2 Comments

HP Laptop, IE9, and Netflix Crash

Well, got done fixing the wife’s HP laptop. Apparently, everytime it would go to netflix.com, IE9 would crash. A look in the event viewer notified me that the Digital Persona Fingerprint plugin was causing the crash. It was attempting to load an IE8 plugin for IE9. Uh, no, I don’t think that will work. So, if you have the above scenario, disable the Digital Persona plugin in IE9 and then you should be able to go to Netflix to watch movies instantly.

Greg

Posted in Personal | 2 Comments

2011 Pictures Posted!

Sorry, I got busy again and didn’t get the pictures posted for 2011 when I had promised but they are there now! They included some of the Royal Gorge train ride we took when the parents were here, Michele’s promotion to Lt. Colonel and then some other pictures of the kids. Enjoy!

Greg

Posted in Personal | Leave a comment

New Pictures and Update

Well, I’ve had some time to get pictures organized finally. I’ve got all of the pictures uploading through 2010 and will be working on 2011 ones this weekend. Sorry, it has taken so long but I have switched image viewers (again) from Silverlight to using LightBox2 which is very nice. I don’t have to manually code each image as now it just looks in a folder and loads them all dynamically.

I also finally got a client’s website updated with a new design – www.bluedolphincottages.com. Check it out!

Greg

Posted in Personal | Leave a comment

WCF Service and Silverlight

Well, I’m venturing out into new technology using WCF and Silverlight 4.0. I learned something today that was quite interesting.

So, my task was to come up with a new web service (now called a WCF Service in 4.0) that can handle encrypting and decrypting strings in a Silverlight application. So, I create a WCF Service (aka Web Service) that would handle the routines on the server side. Then, all I need to do is use the existing class in the Silverlight application right? WRONG! Apparently, Silverlight applications have limited capabilities to namespaces like System.Security.Cryptography and System.Text to just name a few. So, I had to Google to come up with another solution. So instead of using the Rijndael algorithm, I had to use the Rfc2898DeriveBytes algorithm. Worked like a charm!

Anyway, it was a learning day in the world of .NET 4.0 and Silverlight!

Posted in .NET | Leave a comment

Password Keeper v1.83 now available!

Password Keeper v1.83 is now available.  I had to revise the licensing mechanism so if you have licensed your product from an earlier version, you will need to re-request a new license once 1.83 is installed.

Thanks,
Greg

Posted in Software | Leave a comment

Merry Christmas!

Well, the Christmas Holidays are upon us.  As I reflect on this year, a lot has happened in my life with starting the year out with shoulder surgery, to the relocation from Florida to Colorado over the summer, selling a house and renting another, and the career change from being happy at a permanent job in FL to a wonderful contract job in CO (I really did like it!). 

So as we reflect on the year, look back at what has happened in your life, whether good and bad, and learn from it.  Things could be worse but be happy with what you have and don’t envy what you don’t.  Merry Christmas to all my family and friends and we’ll see you back in FL for the holidays!

Posted in Personal | Leave a comment

WebProfile Builder and WAP for VS2010

Oh Microsoft, how I wish you would just make things work consistently.  I’ve been using the WebProfile Builder for my Web Application Projects (WAPs) for quite some time now.  Now that I am converting everything over to .NET 4.0, I have come across a problem when creating a new web application project and how it references Profile properties. 

So, the first thing that you NEED to know: Web Application Projects and Web Site projects are not the same thing!  If you create a Web Site project, the Profile class is automatically generated and you can begin using it by creating your web.config entries and then referring to Profile.whatever in your code.  This is, and has been, not the case for web application projects.

So, amongst my research I have finally figured this out.  The first step is to install the Web Profile Builder version 1.3.  Note that unlike in previous versions, when you open your project and right click on the web.config file, you will NOT see the Build WebProfile option.  You must do a few other things to get this to work.

The next step is to open up your project file (.vbproj or .csproj) and add the following Import line: <Import Project=”$(MSBuildExtensionsPath)\WebProfileBuilder\WebProfileBuilder.targets” />  If you are working on a 64 bit system, make sure you use MSBuildExtensionsPath32 as the WebProfileBuilder will be installed in the Program Files (x86) folder.

You cannot add this Import statement from within the Visual Studio UI so don’t try!  Save the project file and re-open it in Visual Studio.  Next, assumming you have added your profile properties in the web.config, build your project.  After building, click the button to show All Files and you should now see the WebProfile.cs or WebProfile.vb file located just under the web.config file in the Solution Explorer.  Right click on the WebProfile file and include it in your project.  You should now be able to access the Profile properties via Profile class.

Hopefully this will help anyone looking to continue using the Profile class with WAP!

Posted in .NET | 4 Comments