版本NET CORE2.1,對應的autofac 也是最近的基本上問題描述,使用屬性注入,配置一切正常,代碼場景如下public class OrderService : IOrderService
{ public ISiteSettingService SiteSettingService { get; set; }//此處省略多個屬性注入}public class ProductService : IProductService
{ public ISiteSettingService SiteSettingService { get; set; }//此處省略多個屬性注入}其中,兩個 接口 都實現了 自定義接口 IService,并且startup 里邊也是針對 IService類型進行注入。問題來了,項目跑起來之后 ProductService 里邊的屬性注入都生效了, 而OrderService 里邊的注入全是 null, 兩個service 都是同一個程序集,同一個命名空間,都沒有寫顯示的構造函數,什么原因?照理說 ProductService 屬性注入成功,說明注入的配置都是OK的,而且同一個程序集,使用同一個接口注入,都應該得到一樣的結果。什么情況有可能導致這個問題的產生?
添加回答
舉報
0/150
提交
取消