RE: [vsnetaddin] Problems with users who havn't installed all com ponents
- Hi Phil,
I would use approach #1. I would avoid approaches #2 and #3.
Since all accesses to a code model start with a call to
ProjectItem.FileCodeModel or Project.CodeModel (and I suppose that similarly
with VCCodeModel) so can make some function helpers that try to retrieve the
code model, catch the exception if any and returns the code model or null.
Then, make all your code to call those helper functions. It can take some
time but it will make the add-in more defensive (robust is a better
possitive word). I suppose you will need also dual procedures (one for
CodeModel objects and other for VCCodeModel objects). If you are in a hurry
you can supply Microsoft.VisualStudio.VCCodeModel dll separately (assuming
that it is redistributable, which I am not sure of) to the user lacking it
and then start with the approach #1.
Carlos J. Quintero
MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
> -----Mensaje original-----Internet Email Confidentiality footer Este mensaje y cualquier fichero adjunto esta dirigido unicamente a sus destinatarios y pueden contener informacion confidencial. Si usted considera que ha recibido este correo electronico por error (por asunto, por remitente o por cualquier otra causa), le informamos que cualquier revision, alteracion, impresion copia o transmision de este mensaje o de cualquier fichero adjunto esta prohibida y puede constituir un acto ilegal. Por favor, notifiquele el error al remitente respondiendo a este e-mail y elimine el mensaje y su contenido inmediatamente.
> De: firstname.lastname@example.org
> [mailto:email@example.com] En nombre de Phil Jollans
> Enviado el: miércoles, 31 de agosto de 2005 23:32
> Para: firstname.lastname@example.org
> Asunto: [vsnetaddin] Problems with users who havn't installed
> all components
> the installation of my Add-In assumes that Visual Studio and
> all associated
> components are installed, so I don't need to include these
> components in my
> However, one of my users has a very basic VB.NET-only
> installation, where
> some components appear to be missing.
> Specifically, the component
> Microsoft.VisualStudio.VCCodeModel appears to be
> missing. If he deselected everything to do with C++ during
> the installation,
> then this is probably a legitimate situation.
> My Add-In uses appropriate types, e.g. CodeClass or
> VCCodeClass, according
> to the project type, but it may refer to both within the same
> The effect in my Add-In is, that when it tries to enter a
> procedure using
> VCCodeClass, then a System.IO.FileNotFoundException is
> thrown, presumably by
> the JIT compiler.
> Has anybody else had this problem?
> The following solutions occur to me:
> 1. Very defensive programming.
> Place all references to VCCodeModel in separate procedures
> and catch the
> exception. This would surely get messy.
> 2. Distribute Microsoft.VisualStudio.VCCodeModel with my Add-In.
> I am very reluctant to start distributing VS components with
> my Add-In.
> 3. Use late binding.
> I'm not happy with any of these. Does anybody have a better solution?
This e-mail and any files transmitted with it are intended soley for the use of the intended recipients and may contain confidential information. If it appears (from the subject matter or address information or otherwise) that you received this email in error, please note that any review, dissemination, disclosure, alteration, printing, copying or transmission of this e-mail or any file transmitted winth it is prohibited and may be unlawful. Please notify us by return email and delete this email and its contents immediately.