Solved

Namespace Not Found - Add Reference?

Posted on 2006-06-11
22
798 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to dynamically set the form action using jQuery.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

734 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