I am loading a .dll written in Delphi 7 using DllImport within a Windows service written in C# .NET 4. Before deploying this service, I just want to make sure that I don't have to do anything special to handle the unmanaged .dll.
My C# code looks something like this:
[DllImport("MyDelphiDLL.dll")]
private static extern string DoSomething(string value);
private void SomeMethod(List<string> values)
{
foreach (string value in values)
{
string newValue = DoSomething(value);
}
}
The DoSomething
function will be called multiple times, and I suspect that MyDelphiDLL.dll only gets loaded either when the managed .dll gets loaded, or upon the first reference to DoSomething, but I'm not really sure.
I have looked at the DllImportAttribute Class documentation at MSDN, but it doesn't really state one way or the other. I've also searched SO, and Googled the question every way that I can think of, and still haven't found a definitive answer.
I just want to make sure I go about this correctly.
There no problem with what you're doing. The DLL will be loaded once and will stay loaded.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With