2

Here:

Is there a way to specify outlining defaults in Visual Studio 2008 so that a file opens up with members collapsed by default?

..I could find an example for programming addins.. but unfortunately it doesnt compile :-(

Error 1

'CollapsedMembers.Connect' does not contain a definition for '_openHandler' and no extension method '_openHandler' accepting a first argument of type 'CollapsedMembers.Connect' could be found (are you missing a using directive or an assembly reference?)

D:\CollapsedMembers\Connect.cs 77 18 CollapsedMembers

In fact there is no _openHandler there.. I have already tried all the .NET Framework versions but had unfortunately no success.

In OnOpenHandler.cs I have the OnOpenHandler implemented:

namespace CollapsedMembers
{
    internal class OnOpenHandler
    {
        DTE2 _application = null;
        EnvDTE.Events events = null;
        EnvDTE.DocumentEvents docEvents = null;
... and so on...

can anyone help please?

[Edit:] Connect.cs is like following:

using System;
using Extensibility;
using EnvDTE;
using EnvDTE80;

namespace CollapsedMembers
{
    /// <summary>The object for implementing an Add-in.</summary>
    /// <seealso class='IDTExtensibility2' />
    public class Connect : IDTExtensibility2
    {
        /// <summary>Implements the constructor for the Add-in object. Place your initialization code within this method.</summary>
        public Connect()
        {
        }

        /// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary>
        /// <param term='application'>Root object of the host application.</param>
        /// <param term='connectMode'>Describes how the Add-in is being loaded.</param>
        /// <param term='addInInst'>Object representing this Add-in.</param>
        /// <seealso class='IDTExtensibility2' />
        public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            _applicationObject = (DTE2)application;
            _addInInstance = (AddIn)addInInst;


            switch (connectMode)
            {
                case ext_ConnectMode.ext_cm_UISetup:
                case ext_ConnectMode.ext_cm_Startup:
                    //Do nothing OnStartup will be called once IDE is initialised.
                    break;
                case ext_ConnectMode.ext_cm_AfterStartup:
                    //The addin was started post startup so we need to call its initialisation manually
                    InitialiseHandlers();
                    break;
            }
        }

        /// <summary>Implements the OnDisconnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being unloaded.</summary>
        /// <param term='disconnectMode'>Describes how the Add-in is being unloaded.</param>
        /// <param term='custom'>Array of parameters that are host application specific.</param>
        /// <seealso class='IDTExtensibility2' />
        public void OnDisconnection(ext_DisconnectMode disconnectMode, ref Array custom)
        {
        }

        /// <summary>Implements the OnAddInsUpdate method of the IDTExtensibility2 interface. Receives notification when the collection of Add-ins has changed.</summary>
        /// <param term='custom'>Array of parameters that are host application specific.</param>
        /// <seealso class='IDTExtensibility2' />       
        public void OnAddInsUpdate(ref Array custom)
        {
        }

        /// <summary>Implements the OnStartupComplete method of the IDTExtensibility2 interface. Receives notification that the host application has completed loading.</summary>
        /// <param term='custom'>Array of parameters that are host application specific.</param>
        /// <seealso class='IDTExtensibility2' />
        public void OnStartupComplete(ref Array custom)
        {
            InitialiseHandlers();
        }

        /// <summary>Implements the OnBeginShutdown method of the IDTExtensibility2 interface. Receives notification that the host application is being unloaded.</summary>
        /// <param term='custom'>Array of parameters that are host application specific.</param>
        /// <seealso class='IDTExtensibility2' />
        public void OnBeginShutdown(ref Array custom)
        {
        }

        private DTE2 _applicationObject;
        private AddIn _addInInstance;

        private void InitialiseHandlers()
        {
            this._openHandler = new OnOpenHandler(_applicationObject);
        }
    }
}
Community
  • 1
  • 1
jexn
  • 21
  • 3

1 Answers1

1

_openHandler is a member of Connect class and it isn't defined, and you are using it the

private void InitialiseHandlers()
{
    this._openHandler = new OnOpenHandler(_applicationObject);
}

method you copied. You need to define a OnOpenHandler _openHandler member for Connect class.

Ursegor
  • 878
  • 8
  • 16