What is the difference between importing a namespace at the:
1. Project level
2. web.config level
3. Page level
What are the requirements/benefits of each?
If I import a namespace such as System.Collections at the Project level and
the user calls a page that does not use that namespace, is that wasting
resources? Am I better off specifying namespaces for individual pages only?
When exactly are the namespaces in web.config used? Clearly if I do not
include a namespace for a page (or at the Project level) I will get a
compilation error. But why would a namespace ever have to be imported in
web.config? How is that used? 6 1710
Hi MCM,
As for the "project level" importing, do you mean the "Imported namespaces"
for visual basic projects? This is one facility provided by VB.NET project
so that you do not need to explcitly import those namespaces in each code
file. this just help add namespace import , but it still rely on those
assemblies you have "referenced", this is the ultimate things that will
affect your application's generated binary code.
For ASP.NET, the <assembliessection in web.config is not simply importing
namespace, but reference assemblies. For example, the following section
means the four assemblies will be automatically referenced when each of the
ASP.NET aspx page get dynamic compiled(ASP.NET use dynamic compilation)
============
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
========================
Yes, if you add two much useless assemblies here, it will impact your page
assemblies(generated dynamically or via precompilation)'s size. And you can
manually customize the list to minimize it(If you're sure how many ones are
exact necessary).
For page level Import, it is just like code file level import. It make the
certain namespace visible in that page's aspx template scope.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at: ms****@microsoft.com.
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/en-us/subs...#notifications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at http://support.microsoft.com/select/...tance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: =?Utf-8?B?TUNN?= <MC*@newsgroup.nospam> Subject: Imported namespaces Date: Wed, 20 Aug 2008 14:59:01 -0700
What is the difference between importing a namespace at the:
1. Project level 2. web.config level 3. Page level
What are the requirements/benefits of each?
If I import a namespace such as System.Collections at the Project level
and
>the user calls a page that does not use that namespace, is that wasting resources? Am I better off specifying namespaces for individual pages only?
When exactly are the namespaces in web.config used? Clearly if I do not include a namespace for a page (or at the Project level) I will get a compilation error. But why would a namespace ever have to be imported in web.config? How is that used?
As for the "project level" importing, do you mean the "Imported namespaces"
for visual basic projects?
Yes.
This is one facility provided by VB.NET project
so that you do not need to explcitly import those namespaces in each code
file.
But whch is better? Import at the project level or import at the page level?
If I have 10 pages and only 3 pages use a certain namespace, will I be
slowing down the other 7 pages by importing at the project level?
this just help add namespace import , but it still rely on those
assemblies you have "referenced", this is the ultimate things that will
affect your application's generated binary code.
Referenced at the project level or in web.config? They are different -
should I keep them syncronized?
For ASP.NET, the <assembliessection in web.config is not simply importing
namespace, but reference assemblies. For example, the following section
means the four assemblies will be automatically referenced when each of the
ASP.NET aspx page get dynamic compiled(ASP.NET use dynamic compilation)
============
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
========================
Yes, if you add two much useless assemblies here, it will impact your page
assemblies(generated dynamically or via precompilation)'s size. And you can
manually customize the list to minimize it(If you're sure how many ones are
exact necessary).
Same question as above... What is the difference between assemblies
referenced at the project level and assemblies referenced in web.config?
Thanks for your reply MCM,
For your further questions, here is the answer inline:
But whch is better? Import at the project level or import at the page
level?
If I have 10 pages and only 3 pages use a certain namespace, will I be
slowing down the other 7 pages by importing at the project level?
===============================================
For your code behind page class/code, I suggest you use project level
imports since that can help you save the work to declare them in every code
file. However, sometimes (for ASP.NET app), you will write server-side code
in aspx template, in such cases, I think you should always explicitly
import namespace in aspx page, otherwise, you'll need to reference class
via full namespace+classname. Importing namespace will not make page
running slowly, it just help the compiler find classes at compile time(even
for dynamic compilation, its impact is negligible). It won't add assembly
size either.
Referenced at the project level or in web.config? They are different -
should I keep them syncronized?
=================================
For ASP.NET 2.0/vs 2005/2008, there are two web project type(web site
project and web application project). Project Level reference are useful
for web applicaiton project while for web site project, it is
projectless(no much project setting like normal .net project). I suggest
you have a look at this two different project types first: http://msdn.microsoft.com/en-us/libr...80(VS.80).aspx http://www.google.com/search?hl=en&q...ication+projec
t http://webproject.scottgu.com/
As for "web site project", I suggest you always use web.config's reference
list while for "web application project", you can simply use project level
reference. BTW, if you're using Visual studio IDE, you simply use "Add
Reference" menu to reference assemblies and visual studio IDE will help you
do it correctly(according to different project model).
Same question as above... What is the difference between assemblies
referenced at the project level and assemblies referenced in web.config?
============================================
Same as above, the difference is due to the different project type.
Generally, project level reference is used when the certain project build
and generate assemblies at design-time(when you build the project). However
for ASP.NET 2.0 application, it by default use a "web site project" model
which use dynamic compilation(do not generate assembly when you build
project at design-time). Thus, it is necessary to tell the application
which assemblies to reference when it perform dynamic compilation at
runtime(and the web.config assemblies list is used to tell the compiler for
dynamic compilation at runtime).
Some other reference about ASP.NET 2.0 compilation: http://www.west-wind.com/presentatio...tCompilation.a
sp http://odetocode.com/blogs/scott/arc...1/15/2464.aspx
Hope this also helps.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at: ms****@microsoft.com.
--------------------
>From: =?Utf-8?B?TUNN?= <MC*@newsgroup.nospam> References: <D4**********************************@microsoft.co m>
<lV**************@TK2MSFTNGHUB02.phx.gbl>
>Subject: RE: Imported namespaces Date: Thu, 21 Aug 2008 11:39:00 -0700
>
>As for the "project level" importing, do you mean the "Imported
namespaces"
>for visual basic projects?
Yes.
>This is one facility provided by VB.NET project so that you do not need to explcitly import those namespaces in each
code
>file.
But whch is better? Import at the project level or import at the page
level?
>If I have 10 pages and only 3 pages use a certain namespace, will I be slowing down the other 7 pages by importing at the project level?
>this just help add namespace import , but it still rely on those assemblies you have "referenced", this is the ultimate things that will affect your application's generated binary code.
Referenced at the project level or in web.config? They are different - should I keep them syncronized?
>For ASP.NET, the <assembliessection in web.config is not simply
importing
>namespace, but reference assemblies. For example, the following section means the four assemblies will be automatically referenced when each of
the
>ASP.NET aspx page get dynamic compiled(ASP.NET use dynamic compilation)
============ <assemblies> <add assembly="System.Core, Version=3.5.0.0,
Culture=neutral,
>PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add assembly="System.Data.DataSetExtensions,
Version=3.5.0.0,
>Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> </assemblies> ========================
Yes, if you add two much useless assemblies here, it will impact your
page
>assemblies(generated dynamically or via precompilation)'s size. And you
can
>manually customize the list to minimize it(If you're sure how many ones
are
>exact necessary).
Same question as above... What is the difference between assemblies referenced at the project level and assemblies referenced in web.config?
To be clear, you are telling me that if I am using Web Application Project, I
do NOT need to specify any reference assemblies in web.config at all. Is that
correct?
"Steven Cheng [MSFT]" wrote:
Thanks for your reply MCM,
For your further questions, here is the answer inline:
But whch is better? Import at the project level or import at the page
level?
If I have 10 pages and only 3 pages use a certain namespace, will I be
slowing down the other 7 pages by importing at the project level?
===============================================
For your code behind page class/code, I suggest you use project level
imports since that can help you save the work to declare them in every code
file. However, sometimes (for ASP.NET app), you will write server-side code
in aspx template, in such cases, I think you should always explicitly
import namespace in aspx page, otherwise, you'll need to reference class
via full namespace+classname. Importing namespace will not make page
running slowly, it just help the compiler find classes at compile time(even
for dynamic compilation, its impact is negligible). It won't add assembly
size either.
Referenced at the project level or in web.config? They are different -
should I keep them syncronized?
=================================
For ASP.NET 2.0/vs 2005/2008, there are two web project type(web site
project and web application project). Project Level reference are useful
for web applicaiton project while for web site project, it is
projectless(no much project setting like normal .net project). I suggest
you have a look at this two different project types first:
http://msdn.microsoft.com/en-us/libr...80(VS.80).aspx
http://www.google.com/search?hl=en&q...ication+projec
t
http://webproject.scottgu.com/
As for "web site project", I suggest you always use web.config's reference
list while for "web application project", you can simply use project level
reference. BTW, if you're using Visual studio IDE, you simply use "Add
Reference" menu to reference assemblies and visual studio IDE will help you
do it correctly(according to different project model).
Same question as above... What is the difference between assemblies
referenced at the project level and assemblies referenced in web.config?
============================================
Same as above, the difference is due to the different project type.
Generally, project level reference is used when the certain project build
and generate assemblies at design-time(when you build the project). However
for ASP.NET 2.0 application, it by default use a "web site project" model
which use dynamic compilation(do not generate assembly when you build
project at design-time). Thus, it is necessary to tell the application
which assemblies to reference when it perform dynamic compilation at
runtime(and the web.config assemblies list is used to tell the compiler for
dynamic compilation at runtime).
Some other reference about ASP.NET 2.0 compilation:
http://www.west-wind.com/presentatio...tCompilation.a
sp
http://odetocode.com/blogs/scott/arc...1/15/2464.aspx
Hope this also helps.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at: ms****@microsoft.com.
--------------------
From: =?Utf-8?B?TUNN?= <MC*@newsgroup.nospam>
References: <D4**********************************@microsoft.co m>
<lV**************@TK2MSFTNGHUB02.phx.gbl>
Subject: RE: Imported namespaces
Date: Thu, 21 Aug 2008 11:39:00 -0700
As for the "project level" importing, do you mean the "Imported
namespaces"
for visual basic projects?
Yes.
This is one facility provided by VB.NET project
so that you do not need to explcitly import those namespaces in each
code
file.
But whch is better? Import at the project level or import at the page
level?
If I have 10 pages and only 3 pages use a certain namespace, will I be
slowing down the other 7 pages by importing at the project level?
this just help add namespace import , but it still rely on those
assemblies you have "referenced", this is the ultimate things that will
affect your application's generated binary code.
Referenced at the project level or in web.config? They are different -
should I keep them syncronized?
For ASP.NET, the <assembliessection in web.config is not simply
importing
namespace, but reference assemblies. For example, the following section
means the four assemblies will be automatically referenced when each of
the
ASP.NET aspx page get dynamic compiled(ASP.NET use dynamic compilation)
============
<assemblies>
<add assembly="System.Core, Version=3.5.0.0,
Culture=neutral,
PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.DataSetExtensions,
Version=3.5.0.0,
Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
========================
Yes, if you add two much useless assemblies here, it will impact your
page
assemblies(generated dynamically or via precompilation)'s size. And you
can
manually customize the list to minimize it(If you're sure how many ones
are
exact necessary).
Same question as above... What is the difference between assemblies
referenced at the project level and assemblies referenced in web.config?
Thanks for your reply MCM,
That's correct if you haven't use server-side code in aspx template such as
<script runat="server" language="C#" >
....code here....
</script>
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at: ms****@microsoft.com.
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/en-us/subs...#notifications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>Thread-Topic: Imported namespaces thread-index: AckEKQcTLuDbAWDrTa2R60D57qP+gA== Subject: RE: Imported namespaces Date: Fri, 22 Aug 2008 00:31:01 -0700
> To be clear, you are telling me that if I am using Web Application
Project, I
>do NOT need to specify any reference assemblies in web.config at all. Is
that
>correct?
"Steven Cheng [MSFT]" wrote:
>Thanks for your reply MCM,
For your further questions, here is the answer inline:
But whch is better? Import at the project level or import at the page level? If I have 10 pages and only 3 pages use a certain namespace, will I be slowing down the other 7 pages by importing at the project level? =============================================== For your code behind page class/code, I suggest you use project level imports since that can help you save the work to declare them in every
code
>file. However, sometimes (for ASP.NET app), you will write server-side
code
>in aspx template, in such cases, I think you should always explicitly import namespace in aspx page, otherwise, you'll need to reference class via full namespace+classname. Importing namespace will not make page running slowly, it just help the compiler find classes at compile
time(even
>for dynamic compilation, its impact is negligible). It won't add
assembly
>size either.
Hi MCM,
Do you have any further questions on this?
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at: ms****@microsoft.com.
--------------------
>From: st*****@online.microsoft.com (Steven Cheng [MSFT]) Organization: Microsoft Date: Mon, 25 Aug 2008 02:54:45 GMT Subject: RE: Imported namespaces
>Thanks for your reply MCM,
That's correct if you haven't use server-side code in aspx template such
as
> <script runat="server" language="C#" > ...code here....
</script>
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and suggestions about how we can improve the support we provide to you. Please feel free to let my manager know what you think of the level of service provided. You can send feedback directly to my manager at: ms****@microsoft.com.
================================================= = Get notification to my posts through email? Please refer to http://msdn.microsoft.com/en-us/subs...#notifications.
================================================= = This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>>Thread-Topic: Imported namespaces thread-index: AckEKQcTLuDbAWDrTa2R60D57qP+gA== Subject: RE: Imported namespaces Date: Fri, 22 Aug 2008 00:31:01 -0700
>> To be clear, you are telling me that if I am using Web Application
Project, I
>>do NOT need to specify any reference assemblies in web.config at all. Is
that
>>correct?
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Steven Bethard |
last post by:
In the "empty classes as c structs?" thread, we've been talking in some
detail about my proposed "generic objects" PEP. Based on a number of
suggestions, I'm thinking more and more that instead of...
|
by: Random |
last post by:
I'm confused about the proper use and usefulness of namespaces. I beleive I
understand the purpose is so the developer can put classes within namespaces
to essentially organize your code. And I...
|
by: netmeister |
last post by:
Using VB.net in the Page_Load Sub I'm trying to create a dynamic Navigation
control
nothing fancy, nothing tricky.
I dim some variables (below)
Dim tb As Table
Dim row As TableRow
Dim cell...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |