G
Guest
I understand that the means of explicitly linking against native code, is
with an attribute set like this:
[System.Runtime.InteropServices.DllImport("winmm.DLL", EntryPoint =
"PlaySound", SetLastError = true)]
But what if you want the name of the DLL to be dynamic - that is - specified
with a variable rather than a string literal? The above code doesn't compile
if I insert a variable in lieu of the string literal for the DLL name. Is
there a way to do that (perhaps with a different FCL service)?
If it can't be done, I suppose the reason would be that the compiler wants
to collect in advance some type info from the named native DLL, so that it
can construct proper marshalling code. But who knows...
with an attribute set like this:
[System.Runtime.InteropServices.DllImport("winmm.DLL", EntryPoint =
"PlaySound", SetLastError = true)]
But what if you want the name of the DLL to be dynamic - that is - specified
with a variable rather than a string literal? The above code doesn't compile
if I insert a variable in lieu of the string literal for the DLL name. Is
there a way to do that (perhaps with a different FCL service)?
If it can't be done, I suppose the reason would be that the compiler wants
to collect in advance some type info from the named native DLL, so that it
can construct proper marshalling code. But who knows...