Add a common namespace reference by default to all pages in a project

Is there any easy way to add a using statement to every class I create in a project without having to write

using SomeNamespace;

in every file?

[edit] I could add a template I realise but I'm talking about doing it for every file in an existing project.


Note the web.config settings only work for code inside of page markup not in CodeFile/CodeBehind pages, so that's not really a solution.

Another way to do this is to create an empty page with just the right setup you want - namespaces, plus possibly a common base class etc. and then create a page template from that.

Check out File | Export Template...

It's extremely easy and lets you create exactly what you need. Works for most file types as well as entire projects that can be templatized (is that a word? :-})...

Go to "My Project" > "References" tab > "Imported Namespaces" section. Check any namespaces that you want available on every page.

A find/replace across your project of "using System;" with "using System; using SomeNamespace;" will get you most of the way there quickly.

I believe you can do something like:

                    <add namespace="System.IO" />
                    <add namespace="System.Text"/>
                    <add namespace="Westwind.Tools"/>

Need Your Help

Any systematic way to avoid “reentry” problem? (embedded system)

c uml software-engineering embedded-language regression-testing

We are using C to build a system on ARM core (i.e. an embedded system). The question is: how can we avoid reentry problem in a formal way so that we are confident all reentry bugs are removed. This...

Generate a complex database model with MS Entity Framework

.net database entity-framework

I have a database with about 160 tables (it's a shock ! I thought it had about 50...).

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.