Solved

Using an external namespace (C# class)

Posted on 2002-07-12
6
264 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
  • 3
  • 3
6 Comments
 
LVL 4

Accepted Solution

by:
kpkp earned 20 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

808 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