我試圖在Windows窗體應用程序中使用簡單的噴油器。不幸的是,https://simpleinjector.readthedocs.org/en/latest/windowsformsintegration.html的文檔不正確或已過時。簡單的噴油器 - Windows窗體示例破損
當你真正運行的例子,它導致以下錯誤: The configuration is invalid. The following diagnostic warnings were reported: -[Disposable Transient Component] MainView is registered as transient, but implements IDisposable.
此外,我正在創建的應用程序是一個WinForms MVP(被動視圖)項目。我可以將MainView的範圍更改爲單例,並且它可以工作。但對於我來說,由於這個範圍問題,我無法弄清楚如何打開其他窗口。有沒有人在具有多個窗口的真實MVP winforms應用程序中成功使用SimpleInjector?我很好奇看到Presenters,Forms/Views和Main入口點是如何配置的,以及他們的Lifestyle範圍是什麼。
僅供參考,我試過使用LifetimeScoping和ExecutionContextScoping擴展,但絕對沒有任何工作。也許這只是一個PEBKAC問題。
謝謝, 埃裏克