custom namespaces

M

Matt Jensen

Howdy
Relatively new to .NET, I'm trying to create custom a namespace for use in
creating some utility classes, which I seem to have done OK, however, I'm
having a problem trying to use the class with the error the namespace can't
be found.

I've really got no idea what I'm doing, I'm coding in C# and essentially
using notepad, and trying to get my code behind file to use the class in my
custom namespace.

I'm guessing the problem is that I haven't compiled my namespace into a dll,
but I don't have access to the command line compiler on the network PC here
which doesn't help, nor Visual Studio.

I've been told I somehow need to add a reference to my namespace if I was
using Visual Studio, but I don't have it, nor a command line compiler. Is it
possible without these?

Basically, I'm looking for an article that is entitled "how to create and
reference your own namespaces without visual studio".
I've tried putting my code behind and .cs file with my namespace in the bin
directory to no avail.

Any tips greatly appreciated
Cheers
Matt
 
J

Juan T. Llibre

Hi, Matt.

Take a look at :
http://www.asp101.com/articles/john/codebehindnovs/default.asp

If you look at the code in WebForm2.aspx.vb as your codebehind,
but use the Page statement in WebForm3.aspx, you'll have
the answer to your question.

In essence, to use code-behind, you can :

1. use the Visual Studio model
2. compile the code-behind to an assembly and reference it in the aspx
3. use the Src and Inherits properties :
<%@ Page Language="vb" AutoEventWireup="false" Src="WebForm2.aspx.vb"
Inherits="WebForm2"%>

This last one is your answer. Adapt it to your needs.

You will be able to call any class, property or method by using Src,
just like if you were using an actual assembly.
 
M

Matt Jensen

Thanks Juan, but I'm already doing that... - what I need to do is access the
classes in my own custom *namespace* which is essentially in it's own
*standalone* cs (utility) file, and for which I think I must need to compile
it so that the code behind can actually see/find reference to the custom
namespace...
Matt
 
J

Juan T. Llibre

re:
I'm having a problem trying to use the class with the error "the namespace can't be
found."

If I understand you right, in that you're already using src,
then method #2 ( assembly compilation ) is what you need to implement.

There's sample compilation commands in that article.

re:
Well, compiled code doesn't work by osmosis.

Either you use the "src=" method, or you compile to an assembly
from the command-line, if you aren't using Visual Studio.

There's no getting around that.
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,058
Latest member
QQXCharlot

Latest Threads

Top