This article is intended for C # beginners who do not develop DLL programs. The level is limited. Thank you for your understanding.
C # It is impossible to directly debug F5 when creating a dll library. Generally, DLL creates a new DLL project in winform development. in add reference to solution This step must be done!
next, we will add the main Program project to the DLL project in project-Project dependencies.
add the using declaration to the form used. Using , where is the domain name used by the Code In the DLL file.
after this is done, it cannot be used directly. It should be because the methods in the DLL are all in the class, so we can instantiate the class in the DLL and then call the method in it.
------
common error analysis:
1. Why can't I see the class name or cannot instantiate the class after using is added?
cause: no reference is added ...... This step is easy to forget (at least for me ).
2. What if DLL and winform are separated?
method: Release the release, import the DLL in the winform project, or directly use the release DLL when referencing it.
3. Can I call windows DLL?
A: Yes. Use [dllimport] to import the DLL. This is not a development DLL. You can refer to the Windows API reference.