Having changed to a 64-bit development machine at work recently I ran into an Oracle error while trying to generate files using CodeSmith. This error was ORA-06413: Connection Not Open. Assuming it was a connection string error, as I had not ran this particular generation in some time and it was likely that the server or username/password had changed, I proceeded to test the connection from SQL Developer. Success!
After ruling out that the connection was indeed valid I did a quick Google search for the error message. After a few clicks I discovered a very well known (has been around for a few years) Oracle issue; When executing an Oracle command from an application with parentheses or equals — ‘(‘ or ’)’ or ‘=’ — in the path then the specified error message is thrown.
In this particular case CodeSmith had been installed under C:Program Files (x86)CodeSmith which was causing Oracle to fail. The quickest workaround was to simply move CodeSmith from the Program Files (x86) path e.g. into C:CodeSmith. However; there is a patch (5383042) for Oracle 10g, which I believe is also applied to Oracle 11G.
So you’re a smart cookie and you’ve written yourself some scripts to build your DAL or perhaps to deploy or package for a different environment; However, when you want to run said scripts you have to open up a command window, navigate to working folder and run the scripts. Not only is this a pain and waste of valuable time, it also inevitably results in a taskbar full of command prompt windows! Well there is a quick and easy way to add custom buttons to your Visual Studio 2008 toolbar which will fire off your scripts and display the results in the output window.
The first step is to ensure you have a consistent approach to how your projects are set up in order to run your scripts. After all, you don’t want to have to create a unique toolbar button for every single application you’re developing. One simple approach to this is to create a batch file of the same name (e.g. GenerateDAL.bat) for each application which can then call of to project specific actions. Once you have a consistent pattern to your projects your custom toolbar buttons will become much more useful and save you lots of time.
Steps for creating a custom toolbar button:
- In Visual Studio 2008 go to Tools -> External Tools…
- Click Add -> (Complete the form)
Title: (Name of the script e.g. Generate)
Command: (Location of script e.g. $(SolutionDir)CodeSmithCode.Generate.cmd if your script is in the folder ‘CodeSmith’ of all your project)
Arguments: (Leave this one empty if you wish)
Initial directory: (Location of script or the folder level from which you would usually call your script e.g. $(SolutionDir)CodeSmith)
(Check Use output window to display results in the output window)
- Click Ok.
- Right-Click on the toolbar -> Click Customize…
- Select the Toolbars tab -> Click New -> (Enter a suitable name e.g. Scripts)
- Select the Commands tab.
- Under Categories scroll down and select Tools -> Under Commands scroll down to External Command 3 (this assumes you only have to default 2 commands in Visual Studio — if you have more than the external command number will match the order of your external commands list)
- Drag-and-Drop “External Command 3″ and/or any other external commands you created previously.
- Click Close (At this point the button should automatically be renamed to the title of the external command they are linked to).
- Drag the new toolbar group to where you want it on the toolbar and enjoy :-)