C# add a reference using only code (no IDE “Add Reference” functions)

前端 未结 4 1422
攒了一身酷
攒了一身酷 2021-01-13 07:57

I am writting a plugin for a program, and I want to put my code inside a DLL so I can share the plugin freely without exposing (giving away) my code.

Here is the bas

4条回答
  •  Happy的楠姐
    2021-01-13 08:41

    The best option would be to use a framework for creating extensible applications:

    • Managed Extensibility Framework (MEF)
    • Mono.Addins

    If you want to do it manually, you can use the Assembly.Load*() methods to load an assembly at runtime. You can search the assembly for types that implement a specific interface and then create instances using Activator.CreateInstance. The assemblies can be compiled separately, you just have to reference an assembly that contains the interface shared by application and plugin.

    For obfuscation, there are a couple of obfuscation tools available.

提交回复
热议问题