.net dynamic assemblies

后端 未结 2 1950
失恋的感觉
失恋的感觉 2020-12-18 18:59

I was recently asked if I knew anything about Dynamic Assemblies in .Net. The short answer was - I don\'t.

I have found plenty of articles that describe how to creat

2条回答
  •  Happy的楠姐
    2020-12-18 19:52

    This article is a bit dated and the code is a bit 'rustic' but I would say it is one of the most accessible articles regarding dynamic compilation and some of the salient issues.

    It is where I learned to compile assemblies on the fly, both in memory when I did not need to unload or control security, and to a temp file to be loaded with remoting to allow unloading.

    A real world example: An online .net regex tool that accepts c# code for a replacer method that is dynamically compiled into a sandboxed assembly, used to perform the replacement and discarded. This strategy worked just fine, but the possibility of malicious code being injected regardless of sandboxing was just too great so the idea was eventually scrapped.

    Good luck.

提交回复
热议问题