Search code examples
vb.netdlldllimportuser32

Making a DLL in VB.NET which I can use as DllImport


Can I make a DLL in VB.NET which I can use in VB.NET with the tag DllImport just like we import functions from "user32.dll"?


Solution

  • No you can't.

    The DllImport attribute is used to invoke native / un-managed functions from managed code - VB.Net is managed not native, and so you can't run VB.Net functions through DllImport / P/Invoke.

    To use VB.Net functions in other VB.Net projects you should either add a reference to that assembly, use a common referenced interface or base class, or use Reflection.