Solved

Using an external namespace (C# class)

Posted on 2002-07-12
6
231 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
Comment Utility
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
Comment Utility
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
Comment Utility
in that case the class is in the default namespace and should be accessable without a using statement
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 4

Expert Comment

by:kpkp
Comment Utility
just make sure you include aaa.cs in your project.
0
 

Author Comment

by:HStrix
Comment Utility
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
Comment Utility
I got it to work.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
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:…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now