Restrict plug-in assembly code access

后端 未结 3 1796

I\'d like to create a plug-in architecture where I can limit an assemblies API to something very restricted, i.e. only allow a whitelist of functions. Is it possible to res

3条回答
  •  一整个雨季
    2021-01-01 04:29

    using the internal keyword for anytihng you don't want other assemblies to see should work. Am i missing something?

    What you do is this:

    • Make all "full permissions" items internal
    • in the AssemblyInfo.cs, add the InternalsVisibleTo attribute for each assembly you fully trust. Code example: [InternalsVisibleTo("fullNameOfAssemblyFromOtherLibrariesAssemblyInfoFile")]
    • Ta-da, all of your code is secured! (barring Reflection, which you can't really stop anyway)

提交回复
热议问题