Link to home
Start Free TrialLog in
Avatar of champ_010
champ_010

asked on

Namespace Not Found - Add Reference?

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.
Avatar of deanvanrooyen
deanvanrooyen

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>
Avatar of champ_010

ASKER

Hi thanks--what is the PublicKey Token number and Version mean?
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...
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
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?
you can download dotnet reflector and view all properties using that
http://www.aisto.com/roeder/dotnet/
Cool tool but I only get:

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

???
try adding your dll to the GAC and see if that helps

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?
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)
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.
No Objections here

Best of luck champ
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

Avatar of Bob Learned
I don't see where you are adding the DLL as a reference with the /r argument.
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.
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

1) What was the resulting syntax with the /r argument?

2) What errors were you getting?

Bob
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.
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial