c# - Cannot find the interop type'Microsoft.Internal.VisualStudio.Shell.Interop.SVsColorThemeService' -
i building visual studio package/extension using visual studio 2013 update 4 community edition. using standard project template comes visual studio sdk under extensibility projects group.
what need svscolorthemeservice
when add following line in initialize method
var svc = getglobalservice(typeof(svscolorthemeservice)) ivscolorthemeservice;
i 2 build errors:
cannot find interop type matches embedded interop type 'microsoft.internal.visualstudio.shell.interop.svscolorthemeservice'. missing assembly reference? cannot find interop type matches embedded interop type 'microsoft.internal.visualstudio.shell.interop.ivscolorthemeservice'. missing assembly reference?
the referenced assemblies not touched @ all.
so looking svscolorthemeservice
decompiler finds in
// decompiled jetbrains decompiler // type: microsoft.internal.visualstudio.shell.interop.svscolorthemeservice // assembly: microsoft.visualstudio.shell.12.0, version=12.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a // mvid: b8fca7e4-7d13-4e4b-a74b-6b6b01263daf // assembly location: c:\program files (x86)\microsoft visual studio 12.0\vssdk\visualstudiointegration\common\assemblies\v4.0\microsoft.visualstudio.shell.12.0.dll using system.runtime.compilerservices; using system.runtime.interopservices; namespace microsoft.internal.visualstudio.shell.interop { [compilergenerated] [interfacetype(cominterfacetype.interfaceisiunknown)] [typeidentifier] [guid("0d915b59-2ed7-472a-9de8-9161737ea1c5")] [comimport] public interface svscolorthemeservice { } }
as can see assembly referenced. question how hold of svscolorthemeservie
, use proper way?
edit1: after research , following @simon mourier suggestion i've added following code solution:
using system; using system.runtime.compilerservices; using system.runtime.interopservices; namespace microsoft.internal.visualstudio.shell.interop { [comimport] [guid("0d915b59-2ed7-472a-9de8-9161737ea1c5")] [interfacetype(cominterfacetype.interfaceisiunknown)] public interface svscolorthemeservice { } [comimport] [guid("eab552cf-7858-4f05-8435-62db6df60684")] [interfacetype(cominterfacetype.interfaceisiunknown)] public interface ivscolorthemeservice { ivscolortheme currenttheme { get; } ivscolorthemes themes { get; } void _vtblgap1_4(); void _vtblgap2_1(); } [comimport] [guid("98192afe-75b9-4347-82ec-ff312c1995d8")] [interfacetype(cominterfacetype.interfaceisiunknown)] public interface ivscolorthemes { ivscolortheme getthemefromid([in] guid themeid); } [comimport] [guid("413d8344-c0db-4949-9dbc-69c12badb6ac")] [interfacetype(cominterfacetype.interfaceisiunknown)] public interface ivscolortheme { guid themeid { get; } void _vtblgap1_1(); void apply(); } }
what provide missing interfaces com objects. still won't build, throwing same errors + warmings conflicting types.
warning 3 type 'microsoft.internal.visualstudio.shell.interop.ivscolortheme' in 'c:\users\codemaster\documents\visual studio 2013\projects\vspackage1\vspackage1\class1.cs' conflicts imported type 'microsoft.internal.visualstudio.shell.interop.ivscolortheme' in 'c:\program files (x86)\microsoft visual studio 12.0\vssdk\visualstudiointegration\common\assemblies\v4.0\microsoft.visualstudio.shell.12.0.dll'. using type defined in 'c:\users\codemaster\documents\visual studio 2013\projects\vspackage1\vspackage1\class1.cs'. c:\users\codemaster\documents\visual studio 2013\projects\vspackage1\vspackage1\class1.cs 19 9 vspackage1
here link can download sample project: https://drive.google.com/file/d/0b7jbolh-qaqtv09mb1vca3hld1e/view?usp=sharing
some types in vs assemblies require other assemblies (pia). explained here: troubleshooting errors when embedding type information (doug rothaus).
in visual studio specific case, don't know how solve (where assemblies?) other recreate types manually (hint: use tools .net reflector in matter because dll contain definition). example, here how compile code, add somewhere:
namespace myinterop { [comimport, interfacetype(cominterfacetype.interfaceisiunknown), guid("0d915b59-2ed7-472a-9de8-9161737ea1c5")] public interface svscolorthemeservice { } [comimport, interfacetype(cominterfacetype.interfaceisiunknown), guid("eab552cf-7858-4f05-8435-62db6df60684")] public interface ivscolorthemeservice { void _vtblgap1_4(); ivscolorthemes themes { [return: marshalas(unmanagedtype.interface)] get; } ivscolornames colornames { [return: marshalas(unmanagedtype.interface)] get; } ivscolortheme currenttheme { [return: marshalas(unmanagedtype.interface)] get; } } [comimport, interfacetype(cominterfacetype.interfaceisiunknown), guid("98192afe-75b9-4347-82ec-ff312c1995d8")] public interface ivscolorthemes { [return: marshalas(unmanagedtype.interface)] ivscolortheme getthemefromid([in] guid themeid); } [comimport, guid("413d8344-c0db-4949-9dbc-69c12badb6ac"), interfacetype(cominterfacetype.interfaceisiunknown)] public interface ivscolortheme { void _vtblgap1_1(); ivscolorentry this[colorname name] { [return: marshalas(unmanagedtype.interface)] get; } guid themeid { get; } } [comimport, typeidentifier, interfacetype(cominterfacetype.interfaceisiunknown), guid("bbe70639-7ad9-4365-ae36-9877af2f973b")] public interface ivscolorentry { colorname colorname { get; } byte backgroundtype { get; } byte foregroundtype { get; } uint background { get; } uint foreground { get; } } public struct colorname { public guid category; [marshalas(unmanagedtype.bstr)] public string name; } [comimport, interfacetype(cominterfacetype.interfaceisiunknown), guid("92144f7a-61de-439b-aa66-13be7cdec857")] public interface ivscolornames { void _vtblgap1_2(); int count { get; } system.collections.ienumerator getenumerator(); } }
Comments
Post a Comment