私はエラーを取得する:下のある方法でコンストラクタのために型を解決する際にエラーが発生しましたか?
Resolution of the dependency failed, type = "MyAppApp.ServiceAgents.IMyAppServiceAgent", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The type Int32 cannot be constructed. You must configure the container to supply this value.
-----------------------------------------------
At the time of the exception, the container was:
Resolving MyAppApp.ServiceAgents.MyAppServiceAgent,(none) (mapped from MyAppApp.ServiceAgents.IMyAppServiceAgent, (none))
Resolving parameter "AuthHandlerId" of constructor MyAppApp.ServiceAgents.MyAppServiceAgent(System.Int32 AuthHandlerId, System.String AuthSessionGuid, System.ServiceModel.EndpointAddress ServiceEndPointAddress)
Resolving System.Int32,(none)
:
internal ServiceLocator()
{
services = new Dictionary<object, object>();
// fill the map
this.services.Add(typeof(IMyAppServiceAgent), _container.Resolve<IMyAppServiceAgent>());
}
これは私がMVVMから、私は(ViewModelLocatorで標準的な方法を持っている
このメソッドを呼び出す方法ですライトツールキット)メソッド
public static void CreateShowroomLog()
{
if (_showroomLog == null)
{
_showroomLog = new ShowroomLogViewModel(ServiceLocator.Instance(_container).GetService<IMyAppServiceAgent>());
}
}
コンストラクタは
public ViewModelLocator()
{
_container=new UnityContainer();
_container.RegisterType<IMyAppServiceAgent, MyAppServiceAgent>();
}
私はインスタンスを必要としているのクラスがある:
protected static EndpointAddress ServiceEndPointAddress
{
get { return (App.Current as App).ServiceEndpointAddr; }
}
protected static string AuthSessionGuid
{
get { return (App.Current as App).W2OGuid; }
}
protected static int AuthHandlerId
{
get { return (App.Current as App).OriginalHandlerId; }
}
public MyAppServiceAgent(int AuthHandlerId, string AuthSessionGuid, System.ServiceModel.EndpointAddress ServiceEndPointAddress)
{
_proxy = new MyAppService.Service1Client(new BasicHttpMessageInspectorBinding(new SilverlightAuthMessageInspector(AuthHandlerId.ToString(), AuthSessionGuid)), ServiceEndPointAddress);
}
public MyAppServiceAgent()
: this(AuthHandlerId, AuthSessionGuid, ServiceEndPointAddress)
{
}
どのように私はcosntructorでこの問題を解決することができますか?