通用接口中的动态关键字时构建错误

时间:2015-09-17 20:31:51

标签: c# .net dynamic visual-studio-2013 visual-studio-2015

我有通用界面:

public interface IItemDownloader<TResult>
{
   //FROM:  TResult Do<TResult>();
   //TO:
    TResult Do();
}

我没有像这样的实现导致错误:

public class DynamicItemDownloader : IItemDownloader<dynamic>

当我像

一样使用它时
using (IItemDownloader<dynamic> d = new DynamicItemDownloader())
{
    // i get error during build 
    /*
        Cannot implicitly convert type 'DynamicItemDownloader' to 'IItemDownloader<dynamic>'. An explicit conversion exists (are you missing a cast?)
    */
}

神秘的是,当我使用Visual Studio 2013 U5 RC时,我收到此错误。当我尝试通过TFS构建它时,我得到了同样的错误。 当我使用Visual Studio 2015 Enterprise时,我没有收到任何错误,我可以执行代码。 当我想拥有VS2013和TFS的可构建代码时,我必须使用

using (var d = new DynamicItemDownloader())
{
    // this is buildable from TFS and VS2013 without error
}

对我来说这是个谜。知道为什么我会收到此错误吗?有人可以解释我做错了什么吗?

0 个答案:

没有答案