Andrej Tozon's blog

In the Attic

NAVIGATION - SEARCH

TableAdapters & connection strings in VS2005

When you create a new TableAdapter for your DataSet using Configuration Wizard, VS kindly generates new code file for you and adds the specified connection string to application settings. The problem is that connection string also gets included in the auto generated code file and consequently embedded into compiled assembly, which may result in "unexpected behavior" in production environment, like application trying to connect to the wrong server and stuff... Not to mention potential security risks...
To turn this behavior off and store your connection string to configuration file only, select (Connection string) setting in your project's Settings page and switch its GenerateDefaultValueInCode property to false.

Microsoft NTK2005 conference, Portoroz

I'm back from the 10th NT conference, held in Portoroz, Slovenia, where I gave a talk about Visual Studio Tools for office 2005 and had a lab on deploying applications using ClickOnce. I will post PowerPoint presentations and demos on this site in a few days. If you have a question about using these new exciting tools and technology, you're more than welcome to post a comment here or email me.

Patterns & Practices Enterprise Library

If you ever used any of the Microsoft Application blocks  in your application, you'll love the Enterprise Library, released by Microsoft Patterns and Practices group. The library is composed of seven application blocks, all extendable, designed to work together and, what's best, very easy configurable with new  Enterprise Library Configuration Console.

The library includes QuickStart samples (C# and VB.NET), application blocks' source code (with unit tests).

Excellent stuff. Go get it!

The books are here

Every now and then I browse through my Amazon wish list and pick a few items I’d like to have. Three books made it to the latest package that arrived earlier this week: 

·        Steve McConnell's Code Complete (2nd ed.),  After reading so many positive reviews about this book I decided on getting a copy

·        Roger Zelazny’s Lord of Light, a classic Sci-Fi novel, was also recommended to me

·        Holy Blood, Holy Grail (Baigent, Lincoln, Leigh). This one has been on my list for quite some time now. I’ve first heard the story behind Rennes-Le-Chateau about 5 years ago and took immediate interest in it. This book is considered one of the best on the subject

As a developer, I naturally started with Code Complete :). To find out more about this book, go see this interview with the author on MSDN TV. 

VS.NET: File-copying projects and referencing all of them from the same project

I've been asked this question a few times in a last couple of months.

Sometimes you want to shorten the time needed to start up a new project for your component by simply copying the files of an existing, possibly similar project you worked on before. While this solution will generally work, you will encounter some problems when referencing both components (the original and the copy) from the same project in the solution. Sure, you've changed the name of the copied project, all of the files, possibly even the namespace your component resides in. But when you try to add a reference to the new component from the main project, already referencing the original component, nothing happens. There's no warning, message box or anything, and your new component just won't show in the references list.

You check the new project's properties, change the assembly name if you haven't done that already [funny thing - if two or more projects in your solution have the same assembly name assigned to them, the solution will compile without any warning, but you will be stuck with only one executable/dll - the one which compiled last].
Now, all project properties seem alright, but VS still refuses to add the new reference. It's because when you copied the project, you also copied its GUID, an unique identifier, by which, evidently, VS keeps track of the projects.

So, in order to get this thing done, you have to create a new GUID and assign it to the new component project. I haven't found any easier solution, so this is what I would do:

1. Generate new GUID: from the VS Tools menu, select item Create GUID - this will bring up a new window, which will help you create a new GUID for your project. In the GUID Format section select the option 4. Registry format. The resulting GUID will be shown in the result section of the window. You can generate new GUID by hitting the New GUID button. When you're fine with the generated number, click the Copy button, which will copy the number to the clipboard.

2. Paste the GUID in the project file: in your favorite text/XML editor, open the .csproj file, which resides in your new project's folder. Find the text ProjectGuid = "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}" and replace existing GUID with new by pasting it from the clipboard.

3. Save the file and reopen the solution in VS.

I haven't found any better way to do this but it gives me an idea for a VS plug-in...