Click here to Skip to main content
15,918,742 members
Home / Discussions / C#
   

C#

 
QuestionOpenLDAP and .NET Pin
Jan Szumiec2-Feb-06 13:08
Jan Szumiec2-Feb-06 13:08 
AnswerRe: OpenLDAP and .NET Pin
osamahmirza9-Feb-06 17:56
osamahmirza9-Feb-06 17:56 
QuestionOrganizing my project Pin
peterchen2-Feb-06 11:54
peterchen2-Feb-06 11:54 
QuestionLib Files Help please Pin
DocH0liday2-Feb-06 11:53
DocH0liday2-Feb-06 11:53 
QuestionVirual Serial Port Pin
Ross King2-Feb-06 11:43
Ross King2-Feb-06 11:43 
AnswerRe: Virual Serial Port Pin
bskirkman2-Feb-06 17:48
bskirkman2-Feb-06 17:48 
AnswerRe: Virual Serial Port Pin
vikas amin24-Jul-08 11:41
vikas amin24-Jul-08 11:41 
QuestionDelegates from dynamically loaded DLL Pin
Tepel2-Feb-06 11:39
Tepel2-Feb-06 11:39 
I'm currently having a problem, i hope one (or more) of you can help me out.
I have an application that loads DLL's from a directory in a seperate AppDomain. After that it gets the functions i want out of it using the System.Delegate class. So far so good. The functions are proparly loaded etc etc.
The thing is, i can only call the functions from within that particular AppDomain. At least thats what i think the problem is. But i do not want that. I want to be able to define the functions that i need from outside the wrapper that loads the dll's. I can say which functions it needs to pass to me but i cant attach a delegate to it in order to invoke the function.
Since i think the story above might be a bit confusing i'll set up an example.

Example:
<br />
// we have delegate statements<br />
delegate int Foo ();<br />
delegate void Bar (int Foobar);<br />
<br />
// we have our wrapper (note this is a custom class)<br />
dllWrapper Wrapper;<br />
<br />
// we tell which functions we need<br />
Wrapper.INeed("Foo_Inside_DLL", typeof(Foo));<br />
Wrapper.INeed("Bar_Inside_DLL", typeof(Bar));<br />
<br />
// tell the wrapper to start loading in a seperate AppDomain and return the functions it found<br />
FunctionList myFunctions = Wrapper.LoadAll("plugins\\");<br />
<br />
// myFunctions now contains the functions the wrapper found<br />
// Every function is contained in another class called ``Function``<br />
// In that class a System.Delegate is created with the MethodInfo of the<br />
// function and (if needed) an instance<br />
<br />
// lets retrieve the Foo_Inside_DLL function<br />
Function FooFuntion = myFunctions.Find("Foo_Inside_DLL");<br />
<br />
// Lets invoke the function<br />
((Foo)FooFunction.Delegate)();<br />
<br />
// and now im stuck because that doesnt work<br />
// the Function class had the System.Delegate class accessible but!<br />
// I get an exception stating that the DLL from which the function originated was not found<br />
// because of that i think that the Delegate is useless outside the AppDomain in which is was loaded<br />
// Any Ideas?<br />
// if i try the same from withing the Function class it works perfectly<br />
// but then the whole idea of defining outside the wrapper is nullfied<br />
<br />

AnswerRe: Delegates from dynamically loaded DLL Pin
leppie2-Feb-06 11:58
leppie2-Feb-06 11:58 
GeneralRe: Delegates from dynamically loaded DLL Pin
Tepel2-Feb-06 12:14
Tepel2-Feb-06 12:14 
Questionturn GUI program into service Pin
BlackDice2-Feb-06 11:29
BlackDice2-Feb-06 11:29 
AnswerRe: turn GUI program into service Pin
malharone2-Feb-06 11:39
malharone2-Feb-06 11:39 
GeneralRe: turn GUI program into service Pin
BlackDice2-Feb-06 11:54
BlackDice2-Feb-06 11:54 
GeneralRe: turn GUI program into service Pin
Colin Angus Mackay2-Feb-06 12:06
Colin Angus Mackay2-Feb-06 12:06 
GeneralRe: turn GUI program into service Pin
BlackDice2-Feb-06 12:14
BlackDice2-Feb-06 12:14 
GeneralRe: turn GUI program into service Pin
Colin Angus Mackay2-Feb-06 12:20
Colin Angus Mackay2-Feb-06 12:20 
GeneralRe: turn GUI program into service Pin
malharone2-Feb-06 12:11
malharone2-Feb-06 12:11 
GeneralRe: turn GUI program into service Pin
BlackDice2-Feb-06 12:16
BlackDice2-Feb-06 12:16 
AnswerRe: turn GUI program into service Pin
Colin Angus Mackay2-Feb-06 12:02
Colin Angus Mackay2-Feb-06 12:02 
AnswerRe: turn GUI program into service Pin
Andy Brummer2-Feb-06 12:19
sitebuilderAndy Brummer2-Feb-06 12:19 
AnswerRe: turn GUI program into service Pin
bskirkman2-Feb-06 17:53
bskirkman2-Feb-06 17:53 
GeneralRe: turn GUI program into service Pin
bskirkman2-Feb-06 17:55
bskirkman2-Feb-06 17:55 
QuestionC# Class Inheritance Pin
LighthouseJ2-Feb-06 11:16
LighthouseJ2-Feb-06 11:16 
AnswerRe: C# Class Inheritance Pin
Guffa2-Feb-06 11:21
Guffa2-Feb-06 11:21 
GeneralRe: C# Class Inheritance Pin
LighthouseJ2-Feb-06 11:44
LighthouseJ2-Feb-06 11:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.