Friday, April 18, 2014

Visual Studio 2012 stop responding on start-up....possible fix

I don't really know what happened to my Visual Studio 2012 but removing and re-installing did not work. Visual Studio kept not responding when loading up. Finally what seems to have solved it was this simple command line: devenv /ResetSettings. I hope this saves you time...

Saturday, April 12, 2014

How to debug the Seed() method when using EF 6.0

Add this to the Seed() method
  if (System.Diagnostics.Debugger.IsAttached == false)
      System.Diagnostics.Debugger.Launch();
I have tried to use System.Diagnostics.Debugger.Break(), but that crashed visual studio.

NuGet putting the references in a diffrent folder location

I didn't like the default folder Nuget used to put the references. to change the default do the following:

  • Create a nugget.config file under the solution
  • Put the following xml in it
  • Add your nugget packages
<configuration>
  <config>
    <add key="repositoryPath" value="..\Bin\Packages" />
  </config>
  ... 
</configuration>
That's it... you should see your references in a bin\packages folder. (Tested in Visual Studio 2013)

Nuget - changing the default location

just create a file called Nuget.config and put this inside

A Good Database Resource (how to setup your environment for SQL sever and Oracle)

If you want to debug SQL server stored procedure code, or if you want to debug Oracle stored procedures. I found this site to have all the right stuff. Database.ca

Friday, March 14, 2014

Really? there is no String.Truncate in C#...? so here is one...

  public static class StringExtension
  {
      public static string Truncate(this string originalString, int maxSize)
      {
         // check for null
         if (String.IsNullOrEmpty(originalString))
         {
            // return original
            return originalString;
         }

         // validate the size
         if (maxSize < 0)
         {
            throw new ApplicationException("Invalid maxSize for Truncating a string, value must be positive or zero");
         }

         if (originalString.Length > maxSize)
         {
            // trim it
            return originalString.Substring(0, maxSize);
         }
         else
         {
            // return the original
            return originalString;
         }
      }
   }
And the client code will look like this:
         string foo = "1234567890";
         string newString = foo.Truncate(4);