当前位置: 代码迷 >> ASP.NET >> asp.net中怎么把dll写在配置文件或xml中,然后怎么调用dll,请给一个小例子,请高手指教
  详细解决方案

asp.net中怎么把dll写在配置文件或xml中,然后怎么调用dll,请给一个小例子,请高手指教

热度:2611   发布时间:2013-02-25 00:00:00.0
asp.net中如何把dll写在配置文件或xml中,然后如何调用dll,请给一个小例子,请高手指教
asp.net中如何把dll写在配置文件或xml中,然后如何调用dll,请给一个小例子,请高手指教

------解决方案--------------------------------------------------------
C# code
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) );    }  }}
  相关解决方案