T4模板中的DynamicTypeService [英] DynamicTypeService in T4 template

查看:92
本文介绍了T4模板中的DynamicTypeService的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有人在VS2012的T4模板中找到访问DynamicTypeService的方法?在线和在论坛上发布的所有代码始终具有使用GetService()检索对象的相同解决方案.在VS2012中不起作用. 问题在于DTS是抽象类,而不是接口.您将获得的对象是COM对象.因此,当您尝试对其进行转换时,会得到流行的无法转换System._ComObject ...".错误.错误是正确的 因为DTS没有实现任何接口,所以QI无法使用.但是,必须有某种方式来获得这种类型,以便我们可以进行类型解析.我想知道当他们解决T4锁定组件的问题时是否损坏. 有想法吗?

Has anyone found a way to get access to DynamicTypeService from within a T4 template in VS2012?  All the code posted online and in the forums always has the same solution of using GetService() to retrieve the object.  In VS2012 that doesn't work.  The problem is that DTS is an abstract class, not an interface.  The object that you'll get back is a COM object.  Hence when you try to cast it you'll get the popular "Unable to cast a System._ComObject..." error.  The error is correct because DTS does not implement any interfaces and therefore QI won't work.  Yet there has to be some way of getting to this type so we can do type resolution.  I'm wondering if it broken when they resolved the issue of T4 locking assemblies.  Thoughts?

我正在研究使用Project来获取程序集和类型的困难方式,但这是DTS所做的事情,所以这是没有道理的.

I'm looking into doing it the hard way using the Project to get the assemblies and types but that is sort of what DTS does so it doesn't make sense.

Michael Taylor-2013年1月18日
http://msmvps.com/blogs/p3net

Michael Taylor - 1/18/2013
http://msmvps.com/blogs/p3net

推荐答案


这篇关于T4模板中的DynamicTypeService的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆