?
Solved

Using an external namespace (C# class)

Posted on 2002-07-12
6
Medium Priority
?
280 Views
Last Modified: 2010-08-05
Hello Experts,
I'm trying to use a C# class defined in an extra file aaa.cs inside several other bbb.asmx.cs files.
aaa.cs contains global functions.
I expect that it is related to using, alias and namespace.
But I didn't find a good and easy sample to understand that.

Thank you HStrix

0
Comment
Question by:HStrix
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 4

Accepted Solution

by:
kpkp earned 80 total points
ID: 7149608
If you are using Visual Studio, yo need to include aaa.cs in your project.  Right click the project name in the soloution explorer and choose add - add existing item.

At the top of bbb.asmx.cs add a 'using' statement for the namespace defines in aaa.cs

For example if the namespace in the top of aaa.cs is defined as

namespace myAAANamespace

Then you need to put

using myAAANamespace at the top of bbb.asmx.cs

In bbb.asmx.cs You will then have access to the public class(es) defined in aaa.cs
0
 

Author Comment

by:HStrix
ID: 7149870
OK so far,
what do I need to do in the case that aaa.cs does not contain a namespace information.
It only contains a class statment 'public class myglob inherits page'.
0
 
LVL 4

Expert Comment

by:kpkp
ID: 7149924
in that case the class is in the default namespace and should be accessable without a using statement
0
Application Discovery Service in AWS

In the era of the cloud, customers migrating away from their existing on-premise infrastructure. This requires lots of planning, strategies, and effort to identify their existing resources and determine how best to migrate.  Datacenter migrations happen in four phases -

 
LVL 4

Expert Comment

by:kpkp
ID: 7149945
just make sure you include aaa.cs in your project.
0
 

Author Comment

by:HStrix
ID: 7150200
aaa.cs (has class myglob) is now part of the project.
If I'm trying to use the method 'inaaa' in aaa.cs,
I'm getting the message that the method 'inaaa' does not exist in the class or namespace of myproject.bbb.
The project has as members bbb.aspx with code behind bbb.aspx.cs (has namespace myproject and class bbb).

0
 

Author Comment

by:HStrix
ID: 7152133
I got it to work.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question