Software development stuff.

2009-10-15

Xcopy not working from System.Diagnostics.Process.Start()

This one wasn't easy.
See http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/ab3c0cc7-83c2-4a86-9188-40588b7d1a52/
"This is a quirk of xcopy.exe. If you redirect the output, you have to redirect the input as well."

2009-09-07

SQL 2008 - "Saving changes is not permitted."

On SQL 2008 Management Studio Icoudln't save the changes done on a table.
This seemed strange, but was easy to fix:

2009-04-21

Running dynamic javascript generated on the UpdatePanel partial postback

I found this great piece of code that allows a more or less generic way of running javascript generated during the processing of a partial postback within an UpdatePanel.
It runs all the script inside script tags with a certain ID.
http://www.31a2ba2a-b718-11dc-8314-0800200c9a66.com/2008/08/dynamic-javascript-in-update-panel_19.html?showComment=1240338420000#c118959118652221112

Etiquetas: ,

2009-04-17

Stuck with static constructor exception

It took me quite some time to understand why I was getting allways the same exception on a static constructor. So this blog confirmed what I suspected. The exception is cached and thrown again:
http://weblogs.asp.net/avnerk/archive/2008/12/16/static-constructor-throws-the-same-exception-again-and-again.aspx
I found this with .NET2.0 I believe .NET 3.5 works differently since they added this to the documentation:
"If a static constructor throws an exception, the runtime will not invoke it a second time, and the type will remain uninitialized for the lifetime of the application domain in which your program is running"

2009-03-18

Check if 2 dates belong to the same week

I found this post while looking for the solution to the problem in C#.
I endded up using the code:
        public static bool InSameWeek(DateTime d1, DateTime d2)
        {
            DateTime beginningOfWeekDate1 = GetFirstDayOfWeek(d1);
            DateTime beginningOfWeekDate2 = GetFirstDayOfWeek(d2);
            return beginningOfWeekDate1 == beginningOfWeekDate2;
        }
        ///
        /// Considers monday to be the first day of week
        ///
        ///
        ///
        private static DateTime GetFirstDayOfWeek(DateTime d)
        {
            switch (d.DayOfWeek)
            {
                case DayOfWeek.Monday:
                    return d;
                case DayOfWeek.Tuesday:
                    return d.AddDays(-1);
                case DayOfWeek.Wednesday:
                    return d.AddDays(-2);
                case DayOfWeek.Thursday:
                    return d.AddDays(-3);
                case DayOfWeek.Friday:
                    return d.AddDays(-4);
                case DayOfWeek.Saturday:
                    return d.AddDays(-5);
                case DayOfWeek.Sunday:
                    return d.AddDays(-6);
                default:
                    throw new ApplicationException();
            }
        }

Etiquetas:

2009-01-17

Equals on Javascript between different types

Equality with javascript between differetn types has it's pitfalls, for example between bool and string.
Fortunately there is the operator ===
'false' == '' -> true
'false' === '' -> false

See JavaScript pitfalls: null, false, undefined, NaN - MapbenderWiki

2008-11-05

Return a result code from a batch file

How to return a result code (ERRORLEVEL) from a batch file.
exit /B 63
See Batch script return code : return, batch, code, script

Etiquetas: ,