我有一个ISimpleCache<IBrokeredDataObject>类型的类,要添加为App.Config文件中的类型别名(然后是类型)线<typeAlias alias="ISimpleCacheOfIBrokeredDataObject" type="MyApplication.ISimpleCache<IBrokeredDataObject>, MyApplication" />由于显然是错误的,但是我不认为可以将它们转义;<typeAlias alias="ISimpleCacheOfIBrokeredDataObject" type="MyApplication.ISimpleCache&lt;IBrokeredDataObject&gt;, MyApplication" />是正确的。我目前正在撕裂我的代码以使用Unity,因此离可编译的代码库太远了,无法快速对其进行测试,并且希望在这里得到一些确认。 最佳答案 查看this博客文章: In order to write a generic type, use the ` sign followed by the number of generic types that the interface/class receives.在同一页上的评论说: In order to use a constant type in the generic you need to use brackets ([[ ]]).因此,我猜您的配置文件应包含以下内容:<typeAlias alias="ISimpleCacheOfIBrokeredDataObject" type="MyApplication.ISimpleCache`1[[MyApplication.IBrokeredDataObject, MyApplication]], MyApplication" />请注意使用“重音符”或“反引号”字符(`),而不是普通的单引号(')。关于c# - 在Unity App.Config文件中包含通用类,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/454726/
10-11 00:44