Using a namespace without importing

S

sravan_reddy001

how do i use the name space without adding that dll as a reference to
the references of the project
By using only

using ClassLibrary1;

i should be able to access the dll. How to do that. I changed the
Machine.config System.web to this

added the assembly here. but could not get without adding reference
( right clicking on references and adding dll to it in solution
explorer)

<system.web>
<compilation>
<compilers>
<assemblies>
<add assembly="ClassLibrary1" Version="1.0.0.0"
Culture="neutral" PublicKeyToken="8b8ec41060a95b8d"/>
</assemblies>
</compilers>
</compilation>
<processModel autoConfig="true"/>
<httpHandlers/>
<membership>
<providers>
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="LocalSqlServer" enablePasswordRetrieval="false"
enablePasswordReset="true" requiresQuestionAndAnswer="true"
applicationName="/" requiresUniqueEmail="false"
passwordFormat="Hashed" maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1"
passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
</providers>
</membership>
<profile>
<providers>
<add name="AspNetSqlProfileProvider"
connectionStringName="LocalSqlServer" applicationName="/"
type="System.Web.Profile.SqlProfileProvider, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</profile>
<roleManager>
<providers>
<add name="AspNetSqlRoleProvider"
connectionStringName="LocalSqlServer" applicationName="/"
type="System.Web.Security.SqlRoleProvider, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<add name="AspNetWindowsTokenRoleProvider" applicationName="/"
type="System.Web.Security.WindowsTokenRoleProvider, System.Web,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</roleManager>
</system.web>

<a href="http://www.devhood.com/Tutorials/tutorial_details.aspx?
tutorial_id=106">http://www.devhood.com/Tutorials/
tutorial_details.aspx?tutorial_id=106</a>
 
G

Göran Andersson

sravan_reddy001 said:
how do i use the name space without adding that dll as a reference to
the references of the project
By using only

using ClassLibrary1;

i should be able to access the dll. How to do that.

You can't do that. If you don't have a reference to the library, the
project doesn't know about the classes in the library.

The using directive doesn't import anything, it only specifies which
namespaces the compiler looks in.
 
S

sravan_reddy001

The artical was writen in 2001 and targets ASP.Net 1.0.  Is that what you
are running?


No I'm targetting my application to 2.0/3.5 framework. I think there
is something to do in Machine.Config to get that thing included
(without explicitly includeing that)
 
S

sravan_reddy001

You can't do that. If you don't have a reference to the library, the
project doesn't know about the classes in the library.

The using directive doesn't import anything, it only specifies which
namespaces the compiler looks in.



That is, you mean there is nothing we can do with out importing dll
refereneces to our programs
Is there no chance that our application looks for. Since
Machine.Config is the Top Level Global configuration file, I think(but
not 100% sure) we can add those assembly references to Machine.Config.

The assemblies are already registered in the Global Assembly Cache
(GAC). Can our application direcly refer to dll's available in GAC.

Thanks in advance
 
G

Göran Andersson

sravan_reddy001 said:
That is, you mean there is nothing we can do with out importing dll
refereneces to our programs
Is there no chance that our application looks for. Since
Machine.Config is the Top Level Global configuration file, I think(but
not 100% sure) we can add those assembly references to Machine.Config.

No, the compiler has to know about the libraries, and the machine.config
file doesn't apply at compile time.
The assemblies are already registered in the Global Assembly Cache
(GAC). Can our application direcly refer to dll's available in GAC.

No, you need a reference to the library even if it's in the GAC.
 
T

Tom Walker

sravan_reddy001 said:
how do i use the name space without adding that dll as a reference to
the references of the project
By using only

using ClassLibrary1;

i should be able to access the dll. How to do that. I changed the
Machine.config System.web to this

added the assembly here. but could not get without adding reference
( right clicking on references and adding dll to it in solution
explorer)

You could add your dll to the csc.rsp file that the C# compiler uses for
default options (such as assembly references). The csc.rsp file is located
in these folders:
C:\Windows\Microsoft.NET\Framework\v2.0.50727
C:\Windows\Microsoft.NET\Framework\v3.5
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top