Is dynamic compilation in a 'ASP.NET Web Application' possible?

情到浓时终转凉″ 提交于 2019-12-11 04:34:41

问题


Can I somehow utilize the App_code folder in a web application project to compile code on the fly? It'd be great for plugins. Recently Rob Conery demonstrated its use in his talk at MIX 09 in a ASP.NET MVC app. I tried to do the same in a web app but I can't access the classes under App_Code from anywhere else. But if Rob was able to do it in an MVC app, it should be doable in a web application too. After all ASP.NET MVC IS a ASP.NET Web Application under the covers.


回答1:


If you add a code file to the App_Code folder, it should be compiled and available from a code-behind file for a control, or another code file in the App_Code file.

I don't think you'll be able to access it directly from a compiled assembly, since the compiler won't be able to find that reference at compile time.

You'll also need to be aware that App_Code is compiled into a different assembly than your code-behind code, so you can't access internal code across the different assemblies.



来源:https://stackoverflow.com/questions/702498/is-dynamic-compilation-in-a-asp-net-web-application-possible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!