How can I use EnvDTE within a .NET Standard project

2

I'm porting a .net 4.7 project to .net standard, which uses T4 to generate some code. I iterate over the classes, properties and methods. This use to work perfectly, but now the return types of DTE are of type 'System.__ComObject' and I cannot cast them.

Error: Unable to cast COM object of type 'System.__ComObject' to interface type 'EnvDTE.CodeClass'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{B1F42514-91CD-4D3A-8B25-A317D8032B24}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

Any ideas how to fix this?

Example:

public static bool CheckBase(CodeClass codeClass, string baseName)
{
    var bases = codeClass.Bases;
    if (bases != null)
    {
        foreach (CodeClass baseClass in bases)
        {
            if(baseClass.Name == baseName) return true;
        }
    }
    return false;
}
c#
t4
envdte
.net-standard
asked on Stack Overflow Oct 4, 2017 by hvk

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0