Friday, August 17, 2007

MERGE WOES WITH .resx FILES

A few days back, I undertook the task of revamping the GUI of the application that I maintain. The application’s code has been written using VB.NET and Rational ClearCase (2003.06.10+) is the version control/change management tool for the same.


A branch (let’s call it GUI branch) was created off the main branch. The GUI enhancements were performed on this GUI branch. This involved addition of some new controls, changing the properties of some existing controls for one of the form (frmMain.vb) files in the project. After the ‘new and improved’ GUI was given a green, I was faced with the task of merging the GUI branch code with the main branch.


When I attempted to merge the files from GUI branch to main, I received a message to the effect - some of the conflicts could not be resolved by ClearCase, pl. do so via manual merge. The said message was received for the files frmMain.vb (code file) and frmMain.resx (resource file that is automatically generated by .NET). The conflicts in the code file I could resolve, but the .resx file had a large number of conflicts to be resolved (100+). I did complete the manual merge, but obviously I was not sure what I was doing.

Having completed the merge manually I was left w/ code that crashed on execution. That’s when I started searching the Internet high and dry for possible pointers to solving the problem I was facing. I was confident of finding abundant literature on the subject since what I had attempted to do wasn’t anything other-worldly, besides the tools involved were prominent too. I was surprised at not finding much help on the subject. Just as I was about to abandon my search and consider myself ClearCase cursed, I came across this article.


I decided to give KDiff3 a try. On comparing the two .resx files that I was trying to merge I noticed that some of the merge conflicts were due to the insertion of new tags in the middle of one of the files. Clearly if these tags were moved to the end, some of the merge conflicts would disappear.


Unlike ClearCase the merge conflicts in KDiff3 appeared simple to understand and thus resolve. I completed the manual merge of the .resx files via KDiff3. I used KDiff3 as a stand-alone tool and the process was clumsy (copying the .resx files to be merged on my local drive, merging and copying the result to the ClearCase repository). But I got my code to work and was able ship the build! KDiff3 has won my trust.


I must admit that I have not given enough thought about reconfiguring the default IBM® Rational® ClearCase® XML type manager to use KDiff3 when using ClearCase diff merge tools. Whether I will do that sometime soon, is doubtful (for reasons not worth mentioning here). However I wanted to document this mental note here.


To those of you who have come across situations like this and have figured out a work-around; I would like to hear from you.


Another approach that I took to solving this problem was to see if the .resx file would be generated automatically at compile time if it was deleted. In spite of the online reading and hands-on tweaks with .resx files, my understanding of them is still very hazy. Any pointers to understanding resx files will also be greatly appreciated.


On that note…. Tschuss erstmal!





Friday, February 02, 2007

Of TreeView Nodes and their Fonts


If you ever happen to change (upgrade) the font (increase font size or make the font bold) of a node (Class TreeNode) in the TreeView (System.Windows.Forms.TreeView) and run your program, you will be sorry because the label of your node gets clipped!

The only way to work around this is apparently to set the font of your TreeView to the worst case condition; i.e. if you want to make some of the nodes bold then set the font to be bold. Change the font (from Bold to Regular) of the nodes when you actually add the nodes to the treeview.

Here is a quick example -

'Windows form designer generated code

'TreeView Initialization. I only want the root node to be bold, but I set the default FontStyle to Bold

Me.tvwItems.Font = New System.Drawing.Font _

("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))

Private Sub AddNodestoTreeView()

'Create font object to change FontStyle of the nodes other than the root node

Dim Font As Font

Font = New Font(tvwItems.Font, FontStyle.Regular)

'Child nodes added

'Change FontStyle for the nodes other than the root node

CurNode.NodeFont = Font

End Sub

I’d appreciate your inputs on smarter workarounds to this.

TIA!

Thursday, February 01, 2007

A Case for ClearCase


I think I am beginning to like ClearCase; it is - smart enough to do the things that I want it to do, ‘not-so-simple’ that I take its rate its simplicity as dumbness and cryptic enough to have me spend hours researching to find a solution when I am stuck. I quite enjoy the digging it requires me to do; hopefully it is the learning curve that I am slowly conquering. The journey hasn’t been smooth, just when I think things are rolling, I am faced with a quirky problem. I probably should have documented my notes much earlier, for better clarity and accuracy, oh well; here they are for your consumption anyway.

I use Rational ClearCase Explorer 2003.06.10+. I use ClearCase as the version control and change management solution for my VS.NET projects.

ADDING A VS.NET PROJECT TO SOURCE CONTROL –

  1. This is THE recommended way to add .NET project to source control.
  2. If a project has already been added to source control through some other method, then it is advisable to change the source control mechanism ASAP. To do so select the solution/project in the .NET explorer and click on File-> Change Source Control. In the window that appears select the rows and click Bind. The Connected column status for each row should appear checked and the Status column should display Valid after a successful Bind operation.
  3. The .suo and .vbproj files will NOT be added to source control if the recommended method of adding to source control is followed. These defaults should not be changed.
  4. Some ClearCase specific files will be added to ClearCase after this operation. It should be ensured that these files are not moved or deleted.

The next thing that you need to know to use ClearCase is writing config. specs. Unfortunately, I have not found a comprehensive guide that helps with writing config. specs. Do you know of any? Pl. point if you do…

THE EARLY HURDLES -



If you are working with a dynamic view you are likely to view the error above. To get past this hurdle, you will need to change the security settings of your machine. Alternatively you could switch to snapshot views.

CHANGING SECURITY SETTINGS OF YOUR MACHINE

  • Start the .NET Configuration 1.1 tool
  • Double click on Mscorcfg.msc in C:\WINDOWS\Microsoft.NET\Framework\V1.1.4322.
  • Double click on Microsoft .NET Framework 1.1 Configuration by going to Start->Control Panel->Administrative Tools.
    • Click on Runtime Security Policy. Then click on Increase Assembly Trust. Select “Make changes to this computer” and click next. Browse to . Click on open. Click next. Move arrow to Full Trust. Click next. Click Finish. Select “Adjust Zone Security”. Select “Make changes to this computer” and click next. My Computer and Local Intranet should have Full Trust selected. Click Next. Click Finish. Exit window. Restart computer.

    If not done correctly, you might get rid of the above mentioned error, but your code will break on you with the exception below. Time to re-trace steps and make sure security settings are set correctly. (To be honest, I don’t recollect the exact sequence of operations that led to this error.)



    ACCESS DENIED ERROR –

    To fix this, you will need to download and install the hotfix says Microsoft.

    If you are a command-line person, you will probably like to execute ClearCase Commands by clicking -

    Start->Run->cmd

    Hit Enter




    LINKS –

    ClearCase Commands1

    ClearCase Commands2

    ClearCase Book

    VS.NET metadata files