做插件式開(kāi)發(fā),主項(xiàng)目A, 和 子項(xiàng)目BB編譯好之后,把dll 放到了 A項(xiàng)目的 編譯目錄下 xxx\bin\Debug\netcoreapp2.1\Plugins 這個(gè)路徑之下, 然后通過(guò) Assembly.LoadFile( path) 拿到程序集想通過(guò)反射獲取插件內(nèi)容類(lèi)的實(shí)例化對(duì)象,再執(zhí)行 Type.GetType(classFullName) 或者 Assembly.GetType(classFullName), 為什么得到的 type 都是 null ?
1 回答
繁星點(diǎn)點(diǎn)滴滴
TA貢獻(xiàn)1803條經(jīng)驗(yàn) 獲得超3個(gè)贊
以下代碼實(shí)測(cè)通過(guò)
var binPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);var assembly = Assembly.LoadFrom(Path.Combine(binPath, "Plugins/Cnblogs.Web.dll"));var pb = assembly.GetType("Cnblogs.Web.PagingBuilder");
Console.WriteLine(pb.FullName);- 1 回答
- 0 關(guān)注
- 555 瀏覽
添加回答
舉報(bào)
0/150
提交
取消
