locked
Good Tutorial ?? RRS feed

  • Question

  • Hi,

     

    I'm trying to implement a Visual Studio personal plugin in C++ with a COM object. But until now all the steps I've been trough in learning how to extend it seems pointless.

    I implemented the IDTExtensility2 interface.

    I create the "*.addin" file and put it in a searched directory.

    The addin in parsed, I know it since when there's error in it VS let me know.

     

    But somehow the addin is not showed in the addin manager. Right now it is the only thing it is supposed to do!

     

    Does somebody have a good Tutorial for coding an native addin dll?

     

    I've been searching for a week, any answer is welcome. Thanks in advance





    • Edited by baccali Thursday, December 29, 2011 1:17 AM
    Thursday, December 29, 2011 1:09 AM

Answers

  • Why not just use the new project wizard and tell it your AddIn is in C++?  It will create everything you need (including the registry stuff to register your COM object so VS can create it, which is probably what you are missing).

    Ryan

    • Marked as answer by baccali Tuesday, January 3, 2012 5:01 AM
    Thursday, December 29, 2011 1:23 AM

All replies

  • Why not just use the new project wizard and tell it your AddIn is in C++?  It will create everything you need (including the registry stuff to register your COM object so VS can create it, which is probably what you are missing).

    Ryan

    • Marked as answer by baccali Tuesday, January 3, 2012 5:01 AM
    Thursday, December 29, 2011 1:23 AM
  • (including the registry stuff to register your COM object so VS can create it, which is probably what you are missing).

    Ryan

    Hi Ryan, thanks for the Quick Reply.

     

    In fact i'm learning COM at the same time and I want to master it before using any helper ( I think that's why I can't find any good tutorial!).

     

    But you already helped me a lot! thanks. I though it wasn't necessary to register the COM object at the system level since VS 2005 ( http://msdn.microsoft.com/en-us/library/19dax6cz(v=vs.80).aspx ). I will register my dll when i'll have the time and I'll let you know.

     

    Thanks again.

    Thursday, December 29, 2011 1:44 AM
  • The wizard doesn't do anything magical, it just creates files and a project and adds (possibly) a build step to register the dll so VS can locate it in order to CoCreate your AddIn class.  You are free to do it 'by hand', but I don't think you will learn much other than why someone wrote a wizard :)

    I believe the link you are pointing to is talking about the ability to describe your managed AddIns in an XML file, but for native COM based AddIns VS still needs to know what class to CoCreate.  For managed objects it can read from the XML AddIn file and simply use the CLR to create the object, not so for a native component. 

    In creating a C++ AddIn from the wizard it created both code and IDL files as well as an rgs (registry) file and a def which exports some common COM methods like DllGetClassObject and DllRegisterServer (which will write the COM registration info into the registry when called by regsvr32).

    For learning COM I would highly recommend Don Box's book "Essential COM" as it explains the reason behind the COM design and steps through little by little how COM is implemented in Windows, which makes creating COM objects/apps a lot easier imo.

    Ryan

    Thursday, December 29, 2011 2:25 AM
  • Hey, yes it's the book I've learned COM from. :)

     

    OK My Dll is registered (At least it seems to be!) but that doesn't seems to help! Maybe there's an error in it I just coded it. I need to test it with a client.

     

    I didn't know it was just for managed add-in. So how does VS search for a native Add-in? Maybe I need to tell it what class to search for?






    • Edited by baccali Thursday, December 29, 2011 3:20 AM
    Thursday, December 29, 2011 2:56 AM
  • Well, looking at the RGS file the wizard spits out it looks like this

    HKCR
    {
        MyAddin2.Connect.1 = s 'Connect Class'
        {
            CLSID = s '{C8D482D5-9872-4425-9EEC-7942CFDB1DB1}'
        }
        MyAddin2.Connect = s 'Connect Class'
        {
            CLSID = s '{C8D482D5-9872-4425-9EEC-7942CFDB1DB1}'
            CurVer = s 'MyAddin2.Connect.1'
        }
        NoRemove CLSID
        {
            ForceRemove '{C8D482D5-9872-4425-9EEC-7942CFDB1DB1}' = s 'Connect Class'
            {
                ProgID = s 'MyAddin2.Connect.1'
                VersionIndependentProgID = s 'MyAddin2.Connect'
                ForceRemove 'Programmable'
                InprocServer32 = s '%MODULE%'
                {
                    val ThreadingModel = s 'Apartment'
                }
                'TypeLib' = s '{84F0AC20-39F3-4FC2-8612-60D125F1AB0B}'
                }
        }
    }

    HKCU
    {
        NoRemove 'SOFTWARE'
        {
            NoRemove 'Microsoft'
            {
                NoRemove 'VisualStudio'
                {
                    NoRemove '10.0'
                    {
                        NoRemove 'AddIns'
                        {
                            ForceRemove 'MyAddin2.Connect'
                            {
                                val LoadBehavior = d 0
                                val CommandLineSafe = d 0
                                val CommandPreload = d 0
                                val FriendlyName = s 'MyAddin2 - No Name provided.'
                                val Description = s 'MyAddin2 - No Description provided.'
                            }
                        }
                    }
                }
            }
        }
    }

    Which results in the registry entries described above with %MODULE% being replaced with C:\Users\rmolden\Documents\Visual Studio 2010\Projects\MyAddin2\Debug\MyAddin2.dll, which is the location of the built dll.

    Ryan

    Thursday, December 29, 2011 4:37 AM
  • Ok thanks a lot Ryan. I'll give it a try.
    Thursday, December 29, 2011 3:14 PM
  • Hi baccali,

    Have you solve this issue?

    If you have solved, please mark the useful reply as answer.

    Thank you for your understanding!

     

    Best regards,

    Lucy


    Lucy Liu [MSFT]
    MSDN Community Support | Feedback to us
    Monday, January 2, 2012 5:56 AM