.NET动态组件组件、动态、NET

2023-09-04 00:53:35 作者:梦里梦离梦你

我最近问我是否知道动态组件在.net事情。简短的回答是 - 我不

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 create a dynamic assembly but none that truely explain the following:

他们是什么(而不是他们直接从内存中运行) 他们提供了哪些优点静态组件 在其使用的真实世界的例子

任何解释,上面会非常AP preciated。

Any explanations to the above would be very much appreciated.

非常感谢。

推荐答案

的这篇文章 是过时的,有点code是有点'土气',但我会说这是最方便的文章之一关于动态编译和一些的突出问题。

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.

一个真实的例子:一个在线的.NET正则表达式的工具,它接受C#code的替代方法是动态编译成一个沙盒组件,用来进行更换并丢弃。这一战略的工作只是罚款,而是被注入不管沙盒的恶意code的可能性实在是太伟大这样的想法最终被废弃了。

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.

祝你好运。