gpt4 book ai didi

c# - add-in for visual studio 2010编译报错Connect类

转载 作者:太空宇宙 更新时间:2023-11-03 13:53:08 25 4
gpt4 key购买 nike

这里:

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

..我可以找到一个编程插件的例子..但不幸的是它没有编译:-(

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

事实上,那里没有 _openHandler。我已经尝试了所有 .NET Framework 版本,但遗憾的是没有成功。

在 OnOpenHandler.cs 中,我实现了 OnOpenHandler:

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

有人可以帮忙吗?

[编辑:] Connect.cs 如下所示:

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);
}
}
}

最佳答案

_openHandlerConnect 类的成员,它未定义,您正在使用它

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

你复制的方法。您需要为 Connect 类定义一个 OnOpenHandler _openHandler 成员。

关于c# - add-in for visual studio 2010编译报错Connect类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13158584/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com