0

In my application, I am using a user control which is compiled in a separate project.

Assume that my application is named ABC.exe and the name of the user control is bb.dll, and that bb.dll is devloped only to get used in ABC.exe.

In an event of the user control bb.dll, I want to call one public function of ABC.exe

Is it possible to do this?

I am doing this in frame work 3.5

Chris Schmich
  • 29,128
  • 5
  • 77
  • 94
Nidhi Sharma
  • 135
  • 1
  • 2
  • 12
  • Please refer to this question on dynamically loading assemblies:http://stackoverflow.com/questions/1137781/c-sharp-correct-way-to-load-assembly-find-class-and-call-run-method The same concepts might apply to your needs – Ramón García-Pérez Feb 20 '13 at 02:23

2 Answers2

1

Use Assembly.Load to load bb.dll.

For calling method from ABC.exe either

  • reference ABC.exe from BB.DLL during build
  • use reflection to find type/method and call it
  • pass method/class/interface during initialization of the control from class in ABC.exe to class in BB.dll.
Josh Crozier
  • 233,099
  • 56
  • 391
  • 304
Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
0

Since your ABC.exe is refering to BB.dll, you cannot refer ABC.exe from BB.dll as it will become a circular reference. You have to use reflection to load your ABC.exe and then call the function from your eventhandler code of BB.dll.

Manish
  • 510
  • 2
  • 12