是一个“ASP.NET Web应用程序”动态编译可能吗? [英] Is dynamic compilation in a 'ASP.NET Web Application' possible?
问题描述
我可以以某种方式利用一个Web应用程序项目 APP_ code
文件夹来编译code对飞?这将会是伟大的插件。最近罗布科纳展示了其在谈话在MIX 09的ASP.NET MVC应用程序中使用。我试图做同样的在web应用程序,但我不能在 APP_ code
从任何地方访问类。但是,如果罗布能够做到这一点在MVC应用程序,它应该是在Web应用程序也可行。毕竟ASP.NET MVC在幕后一个ASP.NET Web应用程序。
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.
推荐答案
如果您添加code文件到APP_ code文件夹,应该从code-隐藏文件汇编和可用为控制,或者在APP_ code文件的另一个code文件。
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.
您还需要注意,APP_ code编译成不同的装配比你的code-背后code,所以你不能访问的 内部
code横跨不同的组件。
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.
这篇关于是一个“ASP.NET Web应用程序”动态编译可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!