說明
調用Web.dll 文件,獲取其中的所有的WebService
參考
流程
使用LoadFile加載外部dll文件
重點:注意的是,如果查看的對象是外部的DLL,一定要把DLL復制到項目的調試文件夾Debug下。
<add key="PHPWebdll" value="E:\WebIIS\PHP_Publish\bin\BF.Web.dll"/>
//從dll文件中獲取Assembly對象
Assembly assembly = Assembly.LoadFile(System.Configuration.ConfigurationManager.AppSettings["PHPWebdll"].ToString());
//獲取所有的類
Type[] types = assembly.GetExportedTypes();
將 Web.dll相關的dll文件全部復制到程序的調試文件夾debug下面
從E:\WorkDirectory\PublicHealthPlatform\PublicHealthPlatform\BF.Web\bin\
到E:\GitHub\CustomCommonSoft\CommonSoft\bin\Debug\
獲取所有的WebService
思路:命名空間以"BF.Web.WebService"開頭,繼承"System.Web.Services.WebService"類
string sDefaultNameSpace = "BF.Web.WebService";
if (!string.IsNullOrEmpty(item.Namespace) && item.Namespace.StartsWith(sDefaultNameSpace) && item.BaseType.FullName == "System.Web.Services.WebService")
{
string sClassName=item.Name;
}