0
我有以下的接口和實現統一3:類型不具有可訪問的構造
namespace ProjectName.Web
{
public interface IWebUtil
{
}
}
namespace ProjectName.Web
{
public class WebUtil : IWebUtil
{
}
}
在我的配置我有這個註冊。我使用Unity 3
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
<assembly name="ProjectName.Web" />
...
<register name="WebUtil" type="ProjectName.Web.IWebUtil" mapTo="ProjectName.Web.WebUtil">
<lifetime type="transient" />
</register>
...
當我試圖解決這個配置我收到此錯誤:
Exception is: InvalidOperationException - The type IWebUtil does not have an accessible constructor.
-----------------------------------------------
At the time of the exception, the container was:
Resolving ProjectName.Web.IWebUtil,(none)
我已嘗試添加空公共構造,但沒有sucess。
任何人都可以幫忙嗎?謝謝。
您可以發佈您的容器創建和解析代碼?你是否正確地加載配置'IUnityContainer容器=新的UnityContainer() .LoadConfiguration();'? – nemesv