Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以使用通用库创建动态代理,例如Castle Dynamic Proxy没有任何基类或接口?我确实有兴趣在运行时拥有动态的即时类。
Castle Dynamic Proxy
当然,使用 Reflection.Emit 烘焙你的接口,然后将生成的接口类型传递给CreateInterfaceProxyWithoutTarget并提供拦截器。
CreateInterfaceProxyWithoutTarget
请记住,您不能卸载类型,只能卸载应用域,因此如果您要创建数千种类型,您可能最终会陷入性能受损的世界。