locked
VS Package 2010: exception in CodeVariable2 RRS feed

  • Question

  • Hi

    I've been doing VS package migration from 2008 to 2010 and this particular piece of code throws COMException (This method or operation is not implemented) when I try to access "Type" property.

    CodeVariable2 variable = ...
    if (variable.Type.TypeKind == vsCMTypeRef.vsCMTypeRefArray)...

    The actual types of inspected model are strings, lists etc. This works well in 2008 though.

    Is this a known issue and if so - could anyone suggest another way to find out about the variable type?

    Thanks.

    Tuesday, March 26, 2013 10:07 AM

Answers

  • This is probably due to ASL (Asynchronous Solution Load), though I can't explain why it would have worked before. Were you caching some kind of service or data on load? Loading on NoSolution is generally a bad idea, that means on startup. If you code is specifically interacting with code files that is needlessly early.
    • Marked as answer by Min Zhu Thursday, April 4, 2013 6:01 AM
    Wednesday, March 27, 2013 7:05 PM

All replies

  • What language are you inspecting? Every implementation of the code model stuff differs between languages as the code model is extremely language specific in that it has to deal with the language service for a given language, and they all differ.
    Tuesday, March 26, 2013 3:06 PM
  • Oh, sorry, forgot to mention that.

    It's C#.

    Funny thing is - I think this might have something to do with the following:

    [ProvideAutoLoad(UIContextGuids80.NoSolution)]

    Even though I try to inspect my model in IVsSolutionEvents.OnAfterOpenSolution.

    But if I change the auto load to

    [ProvideAutoLoad(UIContextGuids80.SolutionExists)]
    everything works fine.

    • Edited by YuriUkr Wednesday, March 27, 2013 6:35 AM
    Wednesday, March 27, 2013 6:07 AM
  • This is probably due to ASL (Asynchronous Solution Load), though I can't explain why it would have worked before. Were you caching some kind of service or data on load? Loading on NoSolution is generally a bad idea, that means on startup. If you code is specifically interacting with code files that is needlessly early.
    • Marked as answer by Min Zhu Thursday, April 4, 2013 6:01 AM
    Wednesday, March 27, 2013 7:05 PM