Solved

Namespace Not Found - Add Reference?

Posted on 2006-06-11
22
787 Views
Last Modified: 2013-11-19
I created a .cs file with a namespace myNamespace and contains myClass.  Then I opened VS.NET Command prompt and typed:

     csc /out:bin/myTestDLL.dll /target:library myTestFile.cs

It compiled successfully and placed a myTestDLL.dll in my bin directory.  In my .aspx page I placed this on the page:

<%@ Import Namespace="myNamespace"%>

But I get an error: "The type or namespace name 'myNamespace' could not be found (are you missing a using directive or an assembly reference?)"

PLEASE NOTE: I am not building my application in VS.NET even though I have it.  I know you can go into VS.NET and just Add Reference but I really want to know how to do this just from the csc command prompt.  

My file is a Class that doesn't reference any other one I've built.  It uses:

 - System.Security.Cryptography
 - System.Text

What am I missing or doing wrong?   I'm posting on EE because I have Googled and read as many articles as I could find but there's always something missing or not exactly what I need.  Please don't send me links as I have probably read them to no avail and would like an Expert to help me instead.
0
Comment
Question by:champ_010
  • 8
  • 5
  • 3
  • +1
22 Comments
 
LVL 12

Expert Comment

by:deanvanrooyen
ID: 16879943
in your web.config you need to add a reference to the assembly (dll)

something like this
<system.web>
....
<compilation debug="true">
<assemblies>
      <add assembly="myTestDLL, Version=6.0.0.0, Culture=neutral, PublicKeyToken=572826F585F78C3A"/>
</assemblies>
....
</compilation>

</system.web>
0
 
LVL 1

Author Comment

by:champ_010
ID: 16879946
Hi thanks--what is the PublicKey Token number and Version mean?
0
 
LVL 1

Author Comment

by:champ_010
ID: 16879973
O.k I'm supposed to find the Version, Culture, and PublicKeyToken in C:\WINDOWS\assembly

Only problem is I don't see my new dll in there.  What did I do wrong?  It seemed the compiling went well and created the file...
0
 
LVL 27

Expert Comment

by:Sammy
ID: 16879995
see if you can get the key from the compiled dll in your bin directory
just add as a refrence in your project and see if  you can get all of these attributes from there

Good luck
0
 
LVL 1

Author Comment

by:champ_010
ID: 16880016
I am trying to do this without using VS.NET so there's no adding reference to my project.   What else can I do to get these attributes?  Do I have to add it to the GAC?
0
 
LVL 27

Expert Comment

by:Sammy
ID: 16880041
you can download dotnet reflector and view all properties using that
http://www.aisto.com/roeder/dotnet/
0
 
LVL 1

Author Comment

by:champ_010
ID: 16881527
Cool tool but I only get:

Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" for my dll and that doesn't work.

???
0
 
LVL 27

Expert Comment

by:Sammy
ID: 16882006
try adding your dll to the GAC and see if that helps

0
 
LVL 1

Author Comment

by:champ_010
ID: 16891604
Is there not a way to get the dll to work without putting it into the GAC?

Is this the correct way to compile my code into a dll?  

csc /out:bin/myTestDLL.dll /target:library myTestFile.cs

And if so, is that when the Version and PublicKeyToken stuff gets assigned?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 12

Expert Comment

by:deanvanrooyen
ID: 16895596
dont know if this helps

The <publicKeyToken> is a String containing the value of the public key token in hexadecimal format. A null publicKeyToken indicates that the current assembly is private. For additional information about public keys and public key tokens, see Partition II of the CLI Specification.

http://msdn.microsoft.com/netframework/ecma/
Ecma-335*: CLI Partition II – Metadata (word)
0
 
LVL 1

Author Comment

by:champ_010
ID: 17079408
Thanks to all Experts who have tried to answer my questions but I'm thinking of asking Community Support to delete this questions since I haven't received a solution to my question.  I wanted to compile DLLs without using VS.NET and without putting it in the GAC.  I want to be able to use the DLL by importing the namespace.

Does anyone have any comments or objections to this--please let me know.

Thanks.
0
 
LVL 27

Expert Comment

by:Sammy
ID: 17079436
No Objections here

Best of luck champ
0
 
LVL 12

Expert Comment

by:deanvanrooyen
ID: 17085198
I am out out answers here but try and help

how are you compiling the assemblies or are you using a assemblies from 3rd parties?(eg you have no control over them in terms of compilation)

check these out, i am not sure if they will help, it on assemblies and the answer must be in here
http://msdn2.microsoft.com/en-us/library/xwb8f617.aspx

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17087453
I don't see where you are adding the DLL as a reference with the /r argument.
0
 
LVL 1

Author Comment

by:champ_010
ID: 17097201
I've followed as many articles that I can understand (newbie here) including ones that show using the /r argument but I'm not having any luck.

I thought it would be simple enough--similar to: http://www.superdotnet.com/Article.aspx?ArticleID=65 and others like it, but it's not turning out to be very straightforward.  Also some articles talk about things too advanced for me.  Starting to think of getting my hands on VS.NET if that's the only way I can solve this.
0
 
LVL 27

Expert Comment

by:Sammy
ID: 17097244
If you dont want to spend the money on VS.Net, you can always google Free asp.net IDE and you will find a few.
I used sharpdevelop for awhile and found it easy to use http://www.icsharpcode.net/OpenSource/SD/


Best of luck

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17097773
1) What was the resulting syntax with the /r argument?

2) What errors were you getting?

Bob
0
 
LVL 1

Author Comment

by:champ_010
ID: 17100264
I was getting Namespace not found.  I just tried to follow a bunch of tutorials and samples I found online.  I'm not even all too sure I used the /r argument correctly but did follow some code that used it and still unable to get it to work.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 17107724
I don't do this outside of the IDE, but here is the syntax that I believe you need (which is why I asked what you were trying):

csc.exe /t:library /r:bin\SomeDependantAssembly.dll /r:bin\SomeOtherAssembly.dll /out:bin\MyAssembly.dll file1.cs file2.cs file3.cs

Taken from here:
   http://www.developersdex.com/vb/message.asp?p=4105&ID=%3CONrlV%23deGHA.2172%40TK2MSFTNGP04.phx.gbl%3E

With this said, what have you tried, and what problems are you getting?  Descriptive, be descriptive.

Bob
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now