asp.net中如何把dll写在配置文件或xml中,然后如何调用dll,请给一个小例子,请高手指教
asp.net中如何把dll写在配置文件或xml中,然后如何调用dll,请给一个小例子,请高手指教
[解决办法]
namespace PopForums.Data{ public class ClientLoader { public static IPopForumsData Methods() { Cache cache = HttpContext.Current.Cache; if (cache["IPopForumsData"] == null) { if ((ConfigurationSettings.AppSettings["PopForumsDataClass"] == null) || (ConfigurationSettings.AppSettings["PopForumsDataDll"] == null)) // no data layer specified, use the internal one cache.Insert("IPopForumsData", typeof(PopForums.Data.Provider).Module.Assembly .GetType("PopForums.DataSqlClient").GetConstructor(new Type[0])); else { // user has specified an external data layer string assemblyPath = "~\\bin\\" + ConfigurationSettings.AppSettings["PopForumsDataDll"]; string className = ConfigurationSettings.AppSettings["PopForumsDataClass"]; cache.Insert("IPopForumsData", Assembly.LoadFrom(assemblyPath).GetType(className).GetConstructor(new Type[0])); } } return (IPopForumsData)( ((ConstructorInfo)cache["IPopForumsData"]).Invoke(null) ); } }}