Yes, there are problems with eXXXXProjectItemsEvents:
' KNOWN ISSUE: This causes "Catastrophic Error"
m_objeVBProjectItemsEvents =
DirectCast(m_objDTE.Events.GetObject("eVBProjectItemsEvents"),
ProjectItemsEvents)
' KNOWN ISSUE: This causes "Invalid cast"
m_objeCSharpProjectItemsEvents =
DirectCast(m_objDTE.Events.GetObject("eCSharpProjectItemsEvents"),
ProjectItemsEvents)
AFAIK, there is no workaround.
BTW, "System.__ComObject" means that the type is a COM wrapper. This is very
usual in VS extensibility. You can get the actual underlying type with
Microsoft.VisualBasic.Information.TypeName(obj).
There was a thread about this on the MS newsgroups or in the Yahoo forum but
after 5 minutes I have been unable to find it. Anyway I remember that the
conclusion was "no workarounds". MS has not commented on this issue.

Signature
Carlos J. Quintero (Visual Developer - .NET MVP)
The MZ-Tools all-in-one add-in, now for .NET: http://www.mztools.com
> Does anyone have any idea how to attach to the eCSharpProjectItemsEvents in
> C#? These are the events that are associated with Smart Device Applications
[quoted text clipped - 9 lines]
> projectsEvents =
> (EnvDTE.ProjectItemsEvents)dte.Events.GetObject(
"eCSharpProjectItemsEvents"
> );
>
[quoted text clipped - 7 lines]
>
> -Trent
Trent - 14 Oct 2004 21:45 GMT
Carlos,
Thanks for your response. I took your suggestion to figure out the type
of the object being returned and I was able to determine the type as
ICSharpEventsRoot. This was very useful. I was then able to add a reference
to the esproj.dll that comes with Visual Studio in the VC#\VCPackages
directory which has those interfaces defined. Then using the namespace
CSharp, I had access to the ICSharpEventsRoot interface witch in turn allows
you to access the project item events! What a relief to get this out of the
way. Here is what the code looks like:
projectsEvents =
(ProjectItemsEvents)(((ICSharpEventsRoot)dte.Events.GetObject(
"eCSharpProjectItemsEvents" )).get_CSharpProjectItemsEvents( null ));
I have tried it and verified that it works correctly. I don't know if there
is a similar solution for VB Smart Application Projects or not, but it looks
like there may be. Maybe a vb user should try a dll located the Vb7\Bin
directory.
This was definately a tricky one to figure out.
Thanks again,
Trent Barnes
> Yes, there are problems with eXXXXProjectItemsEvents:
>
[quoted text clipped - 47 lines]
> >
> > -Trent
Carlos J. Quintero [MVP] - 15 Oct 2004 10:49 GMT
Wow, you have solved 50% of this problem with Smart Device Projects!
BTW, for those of you who want to avoid the reference to esproj.dll, you can
use late binding (VB.NET code snippet):
Private WithEvents m_eCSharpProjectItemsEvents As ProjectItemsEvents
....
Dim objObject As Object
Dim objCSharpProjectItemsEvents As Object
Dim objType As Type
objObject = m_objDTE.Events.GetObject("eCSharpProjectItemsEvents")
objType = objObject.GetType()
objCSharpProjectItemsEvents =
objType.InvokeMember("CSharpProjectItemsEvents", _
Reflection.BindingFlags.GetProperty, Nothing, objObject,
Nothing)
m_eCSharpProjectItemsEvents =
DirectCast(objCSharpProjectItemsEvents, ProjectItemsEvents)
Now, the other 50% of the problem, eVBProjectItemsEvents, is more tough
because the exception is different. This line causes a "Catastrphic failure"
exception:
objObject = m_objDTE.Events.GetObject("eVBProjectItemsEvents")
So, there is no much thing to do. Any ideas? The DLL for VB.NET is
msvbprj.dll, the namespace is VxExtensibility and the object is
IVxEventsRoot, but since that line causes that exception, we can not get
it...

Signature
Carlos J. Quintero (Visual Developer - .NET MVP)
The MZ-Tools all-in-one add-in, now for .NET: http://www.mztools.com
> Carlos,
> Thanks for your response. I took your suggestion to figure out the type
[quoted text clipped - 19 lines]
> Thanks again,
> Trent Barnes