Add a default shared namespace reference to all project pages

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

using SomeNamespace;

      

in each file?

[edit] I can add a template that I understand, but I'm talking about doing this for every file in an existing project.

+1


source to share


4 answers


Please note that web.config settings only work for code inside the page markup, not on CodeFile / CodeBehind pages, so this is not really a solution.

Another way to do this is to create a blank page with the desired customization you want - namespaces plus maybe a generic base class, etc., and then create a page template from that.



Check out File | Exporting a Template ...

It's very simple and allows you to create exactly what you need. Works for most file types, as well as entire projects that can be scheduled (is that word ?: -}) ...

0


source


Go to My Project> References> Imported Namespaces. Check out all the namespaces you want on every page.



+1


source


Find / replace in your project "using System"; with "using the system, using SomeNamespace"; you will get most of the way quickly.

+1


source


I believe you can do something like:

<system.web>
        <pages>
              <namespaces>
                    <add namespace="System.IO" />
                    <add namespace="System.Text"/>
                    <add namespace="Westwind.Tools"/>
              </namespaces>
        </pages>
</system.web>

      

http://www.west-wind.com/WebLog/posts/2287.aspx

0


source







All Articles