Solved

Namespace Not Found - Add Reference?

Posted on 2006-06-11
22
792 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.NET 5 Templates 2 78
.NET tools for adding thread safety to a web app? 3 31
Error handling in asp.net site 5 24
Fulfillment API php code sample 1 38
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

786 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