473,396 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Need help including a class file...

Ok, so I have my default.aspx page and with it all the contents that it needs for the default.aspx.cs page. What i want to do is seperate parts of the .CS file into a class I would call ServerConnect which will handle all my database setup calls. So I put ServerConnect.cs into the app_code directory. When I run this on my machine locally, it picks up the class file no problem but when I put the machine on a live server I get an error

Compiler Error Message: CS0246: The type or namespace name 'ServerConnect' could not be found (are you missing a using directive or an assembly reference?)

I'm a little bit lost, I've read in numerous places that just adding the .cs file to the app_code directory is all you need to do. I must be missing something, can anyone help me understand how to bring in additional class files into a program?

Or am I just going about this all wrong. My intent is to create several class files that can be called by various programs without duplicating the code all the time. I just think my misunderstanding is that I'm new to ASP, but not new to the C languages.
Mar 20 '07 #1
3 1094
RedSon
5,000 Expert 4TB
In your references you may need to add that class namespace to your project.
Mar 20 '07 #2
I guess I'm not really sure how to do that. My class uses a namespace so in the app_code directory I have a class class.cs and that class is of the namespace "MyClass".

Then in the default.aspx.cs file I add the line
using MyClass;

Then I publish the site without any errors, line 1 of the default.aspx code correctly calls the compiled DLL by name
<%@ page language="C#" autoeventwireup="true" inherits="_Default, App_Web_fogmnhaq" %>

but I get the error

Could not load the assembly 'App_Web_fogmnhaq'. Make sure that it is compiled before accessing the page.

On the server, in \bin is App_Web_fogmnhaq.dll

Is there something that is just so obvious that I am not doing in the setup? Like I said, if I run this all locally on my xp machine using the asp.net dev server it runs fine, once I publish it to a server which is running the latest asp.net 2.0 it doesn't work.

Is there something I need to add to the web.config? Or is it somewhere else in the compiler?

I'm just really lost on this one.
Mar 21 '07 #3
ok, i'm open to admit I was an idiot, actually more like IDIOT.

The problem was not that my code was wrong, it was that IIS wasn't configured properly. Everything runs smooth as silk now.
Mar 21 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: 'Mani | last post by:
Hi, This is just a generic question, where i want to know what is the difference in including a header file in a .h file and .cpp file. I have a class called MyClass (MyClass.h & MyClass.cpp)....
5
by: Learner | last post by:
Hello, Here is the code snippet I got strucked at. I am unable to convert the below line of code to its equavalent vb.net code. could some one please help me with this? static public...
10
by: Luke Meyers | last post by:
So, just a little while ago I had this flash of insight. It occurred to me that, while of course in general there are very good reasons for the conventional two-file header/implementation...
5
by: aaragon | last post by:
Hello everybody, I appreciate your taking the time to take a look at this example. I need some help to start the design of an application. To that purpose I'm using policy-based design. The...
3
by: Milagro | last post by:
Hello Everyone, I'm trying to debug someone elses php code. I'm actually a Perl programmer, with OO experience, but not in php. The code is supposed to upload a photo from a form and save it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.