What's hot ? (and I mean really ...) - scroll down for more
1).  Code Templating - advanced usage of delegates & generics: my slides & demos are available for download! CodeProject article is also available.

2).  My series "TDD in the eyes of a simpleminded" is in progress(including code!): preface, part1, part2, Q&A 1, Manual Stub .vs. Mock Stub

3).  TDD Workshop: SeeCompass v0.1 and v0.2 are out.
# Thursday, July 28, 2005

Hey folks,

I'm sure that all of you encountered this message at least once in your life as a programmer.
Well, I've managed to understand and fix one aspect(\scenario) of the beast:

In my project, I have a directory named "References" which holds all my compiled (in Release mode of course) Dlls which are being used as "black box" component (i.e file reference). Because of all these files are in the VSS and I put them as "Solution Items"(easier deployment), they downloaded to my computer as "Read-only" files. So at the first time the solution builds, no problem, The web project can copy those Dlls (they are not exist in his bin directory), afterwards it's working fine as well (later builds) because there are no changes to this Dlls so the VS.NET simply don't copy them again (like "he" don't compile the ClassLibrary if no changes were made, he's a smart fellow you know).

BUT, in my scenario, I've updated one of those "black box" Dll and I tried to rebuild my solution. You can understand from the title that I got this annoying message that it can't copy the Dll. After I've checked a little, I found out the problematic file in my webproject\bin directory is checked as read-only, So I've unchecked it, rebuild the solution and it worked faultlessly.

If found 2 solutions for this problem:

  1. Call attrib -r [path-to-web-project]\bin\*.dll on pre-build (Build Event) of any ClassLibrary project; I would've put it in my WebProject project but unfortunately it doesn't support Build Events (why MS, why ?)
  2. Go to your "References" directory and manualy set all the files to *NOT* Read-only.
.NET | VSS
Posted by Oren Ellenbogen 
28/07/2005 11:32, Israel time UTC+03:00,     Comments [5]  | 
# Wednesday, July 27, 2005

For some reason, every time I closed my (specific) solution from Visual Studio .NET (2003) the IDE throw an "The operation could not be completed" error. After I've tried to open another(different) solution in the same IDE instance, the solution was not bounded to the VSS !
I swear, this is a regular solution structure... nothing fancy;
After digging a little, and talking about it with Amir (aka "The Markowitz"), we've come to the conclusion that the solution (*.sln) file have problems with the VSS. It became obvious when I tried to add a file to the Solution Items and I simply couldn't check-in the new file.

I've start googling about "troubleshoot VS.NET log" but no luck, I can't seem to find a log file which will give me some more data about the "The operation could not be completed" error. I hate the "restart-your-computer" solutions style, but after I've spent 2 hours exploring the *.sln files, *.csproj files and tried to reproduce the problem on a different solution(tester), I was getting tired and frustrated.

As last resort, I've unbounded the all solution, deleted (permanently) the $/MyProject directory from the VSS and reattached the all solution to the VSS again using the recommended guideline.

Now everything is good, weird ah ?

.NET | VSS
Posted by Oren Ellenbogen 
27/07/2005 12:03, Israel time UTC+03:00,     Comments [5]  | 
# Tuesday, July 26, 2005

I'm working on my Code Generator so it will be able to generate stored procedures for me. Until now I generated the SQL queries in my C# code, but now, due to a development request(\demand) from my client I must work with stored procedures.

The first thing I thought about is how to make my search pages easy to upgrade and maintain if I'm going to use SP(stored procedure). Now, when I need to add another Field to my dynamic where clause, it's quite simple - I'm building the query in my data ccess object according to the parameters and everything is OK. I feared that by using SP for my search pages, I'll need to call something like EXEC which looks like a joke - If you must call EXEC in the SP, you better put the SQL in your C# code and get it over with.

After doing some searches, I found this article which present a way to build and execute dynamic where clauses with "COALESCE" function. After I've searched a little more, I found a similar way to do the same thing with better performance:

" I check the value against NULL and achieve good performance and flexibility. No problem with LIKE values either:

WHERE
(@title IS NULL OR title LIKE @title)
AND
(@min_release_date IS NULL OR release_date >= @min_release_date)
AND
(@document_id IS NULL or document_id = @document_id)

Great performance and flexibility! All indexes are used as expected. " (Zelk)

Looks great !
If the sent parameter is null, don't "cut" the results by the parameter, else - use it...

OK, I must dig into my generator and start implementing this... 

Posted by Oren Ellenbogen 
26/07/2005 05:13, Israel time UTC+03:00,     Comments [6]  | 

Sometimes my VS.NET just can't "catch" my breakpoints in my .js files for some reason.
Yes, I made sure that the "Script" box is checked on the attached process, still, no luck.

Fortunately debugger; command is in the house !

It's simple to use and it can be great for production debugging as well.

example (in myexample.js file):
function MyMethod()
{
   debugger; // ==> this will make the debugger to take over (you can use VS.NET or any other suitable program).   

   // your code to debug here.
}

Posted by Oren Ellenbogen 
26/07/2005 02:08, Israel time UTC+03:00,     Comments [1]  | 
# Monday, July 25, 2005

Damn, such a long title... I must take a minute to relax; Done -

I had to change the directory name of my Web project in order to ease my build process.
Well, I must admit, this isn't an easy task when you don't remember the steps or you're too
tired to messing around with it (rule of thumb: gather the required powers, it won't get easier to adjust it later you know).

So, from my experience here are the steps for changing the VSS bounded ASP.NET project
directory name without killing your VSS\Solution:

  1. Close the solution if it's open (i.e - close the Visual Studio .NET).
  2. Create the new directory name you want to address the ASP.NET project into.
  3. Go to the IIS (Ctrl + Q -> iis, oh wait, assuming you've followed my advice and installed SlickRun) and change the virtual directory path to point to the new directory.
  4. Open the *.sln file with notepad (right-click->open with...) and find "SccLocalPath[number]" which points to your current(unwanted) directory name; overwrite the directory name with the new directory name.
  5. Delete the *.suo file - NOTICE: this is a hidden file so you must check the option to view all the hidden files (OS configuration). This file keeps the user configuration about the solution (like what is my StartUp project\file etc.)
  6. Open the *.sln via VS.NET and you'll get a window which will ask you to choose the web project path (http://localhost/VirtualDirectoryName_1) - remove the "_1" suffix and click OK.
  7. Delete the old web project directory. TIP: if you're trying to delete the old web project directory and you'll get an error that there are files in use - try to delete VSWebCach directory (in your c:\Documents and Settings\[username]) and then try to delete the directory again.
  8. Drink something and relax, you deserve it !
.NET | VSS
Posted by Oren Ellenbogen 
25/07/2005 07:41, Israel time UTC+03:00,     Comments [1]  | 
# Sunday, July 24, 2005

I'm struggling with myself about what's the best way now to create an automated build mechanism for my dotNET project. I read a lot during the last weekend about using Nant and Nant Contrib and I've managed to pull something off quite easily. * I'll upload the build file and my remarks about the process as soon as I'll finish (Can't wait ah ? ;-)).

I saw that Microsoft shipped their automated tool - MSBuild - with VS.NET 2005 (beta 2); But in order to make use of MSBuild in my v1.1 .NET framework, I'll need to do some DIRTY hacks which I don't seem to like in this case. You ask yourself why ?

1. This is a beta version, meaning the bugs will be all over me !

2. I personally think that using the beta version of any program in my Production environment is a big risk, too big in my opinion.

3. Let's say that I found a bug and I need to get it fixed; MS will cry that this version isn't supported in v1.1 framework (dah! that's why I did my dirty hack) and in any case it's only a beta and I need to wait for the final release - and they'll be right ! (damn, I hate when it happens).

4. NAnt is an old(sorry... but I mean it as a compliment) open source freeware - there are less bugs and I can always dig in and make the required changes !

Therefore, I'm thinking of staying with NAnt just until the final release of MSBuild will be available.

What do you think ?

Posted by Oren Ellenbogen 
24/07/2005 08:01, Israel time UTC+03:00,     Comments [0]  | 
# Friday, July 22, 2005

I'm always trying to make my project deployment as easy as possible.
 
One of the "problems" I've encountered is keeping my solution structure, that is:
- MySolutionDirectory
      - MyWebProject
      - MyBusinessLayerClassLibrary
      - MyDataAccessLayerClassLibrary
      - MyEntitiesClassLibrary
      - etc.
 
This is hard to do, especially when the "Add Web Project" creates a virtual directory in
my wwwroot directory by default which breaks my desired structure.
 
When I want to initialize the Solution or to pull the entire solution from the
VSS (e.g - on a new programmer station) I need to take these steps beforehand -
  1. Create the directory [solution-path]\[web-project\webservice name]
  2. Go to my IIS and add the required virtual directory which will redirect to step 1 path.
Otherwise, the VS.NET will create the web folders in my wwwroot automatically, which will again break my preferred structure.
In addition, in some of my solutions, I have more than 1 web project\webservice and repeating these steps can get very annoying.
 
So, after reading about IIS API, I've created an IIS helper utility for creating virtual directories by
demand in one-click EXE.
 
The configuration file is quite simple:

<VDSettings>
    <Directories>
        <Directory>
            <DirectoryPath>C:\Projects\MySolution\MyWebProject</DirectoryPath>
            <VirtualDirectoryName>MyWebProject</VirtualDirectoryName>

        </Directory>
        <Directory>
            <DirectoryPath>C:\Projects\MySolution\MyWebShareProject</DirectoryPath>
            <VirtualDirectoryName>MyWebShareProject</VirtualDirectoryName>
            <CreateUnder>MyWebShareProject</CreateUnder>
        </Directory>
    </Directories>
</VDSettings>

This sample demonstrates how to add "MyWebProject" Virtual Directory and create another
Virtual Directory, under "MyWebProject", named "MyWebShareProject".
 
* 2 Notes:
  1. You can create the virtual directory under a WebSite by using "WebSiteName" element under the "Directory" element.
  2. If the "DirectoryPath" doesn't exist - the utility will create it before setting the Virtual Directory path.
 
Now, when a co-worker in my company is trying to deploy my solution on his station, all he needs to
do is to run VDCreator.exe and he can continue the deployment via VS.NET -> "Open From Source Control..." option.
 
That's what I call "child's play" deployment.
 
The files:
VDCreator bin1.zip (4.62 KB)  (EXE & config file only)
VDCreator Source.zip (9.64 KB) (Source files included)
Posted by Oren Ellenbogen 
22/07/2005 12:38, Israel time UTC+03:00,     Comments [1]  | 
# Wednesday, July 20, 2005

After logging in, be sure to visit all the options under Configuration in the Admin Menu Bar above. There are 26 themes to choose from, and you can also create your own.

 

Posted by Oren Ellenbogen 
20/07/2005 09:00, Israel time UTC+03:00,     Comments [0]  | 
# Sunday, July 17, 2005

My friend Moran sent me a great link which will improve your vocabulary for sure.
 
Come on, give it a try.
 
Posted by Oren Ellenbogen 
17/07/2005 10:07, Israel time UTC+03:00,     Comments [0]  | 

Add a new Solution and Projects to the VSS:
 
DONT -
Count on the VS.NET => "Add Solution to Source Control..." to add your solution
and projects to the VSS.
It will create such a mess in the VSS, a mess you'll find difficult to clean up later on, that you'll be
sorry for the moment you've chosen this option.
In addition, it will not give the desired (and recommended) structure:
 
MySolution
   - MyWebProject
   - MyClassLibrary1
   - MyClassLibrary2
   - ...
 
 
DO -
Follow the steps in this great post. I truly believe this link is a MUST
for every developer who's working with VS.NET and VSS on a daily basis.
 
I hope this will help you all...
 
 
 
 
.NET | VSS
Posted by Oren Ellenbogen 
17/07/2005 09:42, Israel time UTC+03:00,     Comments [2]  |