Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing a custom namespace problem

Status
Not open for further replies.

motte

Programmer
May 31, 2001
155
US
Hi all,

I am trying to import a custom class into a .aspx file. These files are not done in VS.net (just a text editor). The .aspx file has no code-behind. Its all in-line. But I want to import a class that I created. The class is called Monitor.cs with a namespace of SiteMonitor. To make is simple, this class is in the same directory as the .aspx file. When I try to import Monitor.cs, I get the following error:
Namespace or type 'Monitor' for the Imports 'SiteMonitor.Monitor' cannot be found.

This is done on a hosting provider. Does anyone have any ideas on how I can import this, or what I have to do so I can create an object of the class?

I am not trying to inherit from the class. I just want to create an object so I can access methods.

Mike
 
Your project needs a reference to the .dll. I cannot tell you how to do this w/o VS. Sorry.

ps. if you can afford it, I would seriously consider moving to VS. I took a class about a year about called "Notepad VS Visual Studio"

The basis of the class was to introduce the .NET framework first in notepad, and then in VS so attendees could see the power of VS. It was an 8 hour session, and the first 6.5 hours of it was doing a simple app in notepad. It then took the speaker the remaining 1.5 hours to complete the same project in VS. Pretty powerful message there.

I'm all about getting to know things "under the covers" and whatnot, but I'm also about productivity, and would say that it's more important most of the time, to be able to get things done exponentially faster.

Anyway, I'll step off the soap box now.

Hope you get it figured out.

:)
paul
penny1.gif
penny1.gif
 
Link9,

Thanks for the response and for the advice. I'm learning both, VS.net and its languages in notepad as well. This particular project was started before we had a license for Visual Studio so we are finishing it up this way. But I did figure it out:
Code:
<%@ Assembly src=&quot;path/to/class/class.cs&quot;  %>

Mike
 
motte,

Another way of handling this problem is to compile the .cs file (if you don't know how, look into running 'csc' from command prompt) and put the outputted .dll into your root /bin folder. From there, all you need to do is add an <%@ Import Namespace=&quot;[Your Custom Namespace Name]&quot; %> from within your code. This allows for two things: 1) your backend code runs faster than non-compiled code, and 2) you can keep your source code away from unwanted eyes.

PS->If you can learn to do complete projects using nothing but Notepad, my (personal) suggestion is DO IT! I have both tools at my disposal: VS Pro and Notepad. I tend to use Notepad as my main development tool and VS as reference. I find that creating a web app with less overhead is done more easily when you're not dealing with somebody else's (M$'s) automatically generated source code. True, it does take quite a bit of time to become proficient in creating apps using Notepad (it took me almost two months), but I think that the end result is much more worthwhile than just using VS. -----------------------------------------------
&quot;The night sky over the planet Krikkit is the least interesting sight in the entire universe.&quot;
-Hitch Hiker's Guide To The Galaxy
 
AtomicChip,

Thanks for the reply. That sounds like an idea I must try.

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top