473,395 Members | 1,872 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,395 software developers and data experts.

Reference .cs File From .cs File

I have two classes and a web page: test1.cs, test2.cs, and test.aspx.
I know how to add a reference to test1.cs from test.aspx using the
assembly directive (<%@ Assembly Src="test1.cs" %>). This works fine,
but what if test1.cs needs to call a method from test2.cs. How can I
add a reference to test2.cs from test1.cs without compiling either?

--------test.aspx--------
<%@ Page Language="C#"%>
<%@ Assembly Src="test1.cs" %>
<%@ Assembly Src="test2.cs" %>

<script runat="server">
void Page_Load() {
Response.Write(ns1.ClassOne.SomeMethod());
Response.Write("<br>");
Response.Write(ns2.ClassTwo.AnotherMethod());
}
</script>
--------test1.cs--------
namespace ns1 {
public class ClassOne {
public static string SomeMethod() {
return "return from SomeMethod class one";
//How do I call AnotherMethod() from here???
}
}
}
--------test2.cs--------
namespace ns2 {
public class ClassTwo {
public static string AnotherMethod() {
return "return from AnotherMethod class two";
}
}
}
Nov 18 '05 #1
1 3148
inheritance

--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
"David" <da*********@zoomtown.com> wrote in message
news:36**************************@posting.google.c om...
I have two classes and a web page: test1.cs, test2.cs, and test.aspx.
I know how to add a reference to test1.cs from test.aspx using the
assembly directive (<%@ Assembly Src="test1.cs" %>). This works fine,
but what if test1.cs needs to call a method from test2.cs. How can I
add a reference to test2.cs from test1.cs without compiling either?

--------test.aspx--------
<%@ Page Language="C#"%>
<%@ Assembly Src="test1.cs" %>
<%@ Assembly Src="test2.cs" %>

<script runat="server">
void Page_Load() {
Response.Write(ns1.ClassOne.SomeMethod());
Response.Write("<br>");
Response.Write(ns2.ClassTwo.AnotherMethod());
}
</script>
--------test1.cs--------
namespace ns1 {
public class ClassOne {
public static string SomeMethod() {
return "return from SomeMethod class one";
//How do I call AnotherMethod() from here???
}
}
}
--------test2.cs--------
namespace ns2 {
public class ClassTwo {
public static string AnotherMethod() {
return "return from AnotherMethod class two";
}
}
}

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Pablo J Royo | last post by:
Hello: i have a function that reads a file as an argument and returns a reference to an object that contains some information obtained from the file: FData &ReadFile(string FilePath); But ,...
3
by: Whoever | last post by:
To create Excel file, you can Add Reference Visual Studio.NET, browse to ... and then select Microsoft.Office.Interop.Excel, etc. It endsup some reference to GUID in project file. You can then...
6
by: trexim | last post by:
Hi, I am trying to create a Web Reference for CSTA using the URL http://www.ecma-international.org/standards/ecma-348/csta-wsdl/csta-wsdl-all-operations.wsdl Visual .Net complains that: "...
4
by: dhnriverside | last post by:
HI guys I've just written my first independent namespace for my library (yay me!). However, on trying to add it to my website project, it causes an error when I look at the website. It compiles...
3
by: Adam | last post by:
We have a web site that uses .vb for the web pages and .cs for a class module. We are getting the error in .NET 2.0 and VS 2005 beta 2. It does work with .NET 1.1. When trying to access a page...
2
by: Suzanne | last post by:
Hi all, I'm reposting this message as I'm experiencing this problem more and more frequently : I really hope someone out there can help me as I've been tearing my hair out on this one for a...
3
by: Richard Lewis Haggard | last post by:
We are having a lot of trouble with problems relating to failures relating to 'The located assembly's manifest definition with name 'xxx' does not match the assembly reference" but none of us here...
2
by: AMDRIT | last post by:
Hello Everyone, I am having an issue with my solution and hoping that you all can suggest a resolution. I have a common library that (A) that three other projects make reference of (B,C,D). ...
3
by: Mike | last post by:
I have a web app that is referencing several web services. When I make a change to a web service (add, modify a method), I have to 'Add Web Reference' for the changes to take affect. If I do 'Update...
3
by: drop | last post by:
Hi all, I'm trying to figure out how references works in Web Application Projects. We have a third party dll that we use in many projects. I've created a folder containing that DLL. That way,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.