using delegate between different assembly

  • Thread starter Thread starter somequestion
  • Start date Start date
S

somequestion

i'd like to use delegate but it is not in same assembly.
how should i do to solve this...
source code is like below...

using B;
namespace A
{
class A
{
funcA()
{
B b = new b();
b.B();
}

funcCallB()
{
// this method will call class B
}
}
}

namesapce B
{
class B
{
funcB()
{
// i'd like to call funcCallB of call A forexample like below..
// but it's not possible...and delegate can't use because of
namespace is different
// how can i solve this problem???
A a = new A();
a. funcCallB();
}
}
}
 
somequestion said:
// i'd like to call funcCallB of call A forexample like below..
// but it's not possible...and delegate can't use because of
namespace is different
// how can i solve this problem???
A a = new A();
a. funcCallB();

1) Make the class and function "public":
public class A...
public void funcCallB() ...

2) To access the different namespace, prefix the class name with the
adequate namespace, which in your example code hapens to have the same name
as the class although this is not recommended because it can lead to
confusion:

A.A a = new A.A();
a.funcCallB();

3) In order for this to work, you need a reference from the calling
assembly into the called assembly. This is not reflected in the source code;
you have to configure it in Visual Studio, or provide it as a -r parameter
if you are compiling from the command line.

4) Notice that none of this is related to delegates. Delegates are a
different thing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top