昨天我实现了这段代码:
CustomerProductManager productsManager = container.Resolve<CustomerProductManager>();
原本代码可以编译和运行。
今天(可能修改了一些东西),我不断地收到以下错误:
The non-generic method 'Microsoft.Practices.Unity.IUnityContainer.Resolve(System.Type, string, params Microsoft.Practices.Unity.ResolverOverride[])' cannot be used with type arguments
我的同事有相同的源代码,但没有同样的错误。为什么?如何解决这个问题?
P.S.
导入部分已包含 "using Microsoft.Practices.Unity;"。
我尝试使用非泛型版本替换泛型版本:
CustomerProductManager productsManager = (CustomerProductManager)container.Resolve(typeof(CustomerProductManager));
出现了另一个错误:
没有重载方法“Resolve”接受'1'个参数
看起来好像其中一个程序集没有被引用...但是是哪一个呢?我已经引用了两个程序集: 1. Microsoft.Practices.Unity.dll 2. Microsoft.Practices.ServiceLocation.dll
P.S. 我曾经看到类似的问题http://unity.codeplex.com/WorkItem/View.aspx?WorkItemId=8205,但它被解决为“不是错误”
任何想法都会有所帮助