Coder Social home page Coder Social logo

kbilsted / notepadpluspluspluginpack.net Goto Github PK

View Code? Open in Web Editor NEW
162.0 16.0 52.0 1.14 MB

.Net package to install into visual studio to make plugins for Notepad++

License: Apache License 2.0

C# 95.66% PowerShell 0.22% Python 4.12%
notepad notepad-plugin notepadplusplus notepad-plusplus-plugin csharp visual-studio

notepadpluspluspluginpack.net's Introduction

NppPlugin .NET package for VS2019 and beyond for Notepad++ 32bit and 64 bit...

What is this? Its a simple template for very fast and easy building plugins for Notepad++ in C#/.Net

This is a fork of UFO's plugin package updated for VS2015, 2017 and 2019

Build status License Stats Stats

Getting started

  1. Download a release
  2. Place the visual studio project template (the NppPlugin.zip) in the visual studio path (typically "My Documents\Visual Studio 20xx\Templates\ProjectTemplates\Visual C#\")
  3. If you intend to debug Notepad++ itself (and not just the plugin) ensure you have installed Visual C++ from the visual studio installer
    install CPP
  4. Create a new project inside Visual studio using file -> new -> project -> visual C# -> Notepad++ project
  5. Build (building will copy the dll to the Notepad++/plugins folder)
  6. Start Notepad++ and activate your plugin from the plugins menu

Upgrading to a newer version

  • Upgrading the pluging package

    • replacing the NppPluginXXXX.zip from your visual studio (typically "My Documents\Visual Studio 20xx\Templates\ProjectTemplates\Visual C#\") with a newer version
  • Upgrading plugings using the plugin pack.

    • Delete the folder PluginInfrastructure and copy over that folder from a newer version of NppPluginXXXX.zip
    • Open visual studio
      • Click "show all files" in the "solution explorer"
      • Select the new files, Right-click and choose "include in project"

Plugins using this pluginpack

If your plugin is not on the list, please make a PR with a link to it.. :-)

How to start coding plugins

First read the the demo-plugin code. It is actively being maintaned - see https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net/tree/master/Demo%20Plugin it is a spin-off of Don Ho's http://download.tuxfamily.org/nppplugins/NppPluginDemo/NppPluginDemo.zip

Overall plugin architecture

Plugins can interact with Notepad++ or the underlying Scintilla engine. The plugin pack provides two classes to make this interaction easier. This is NotepadPlusPlusGateway and ScintillaGateWay which are thin layers making interaction more pleasant (and testable!).

If you are interested in low-level access you can use the Win32 api also included in the plugin pack.

The architecture of the plugin is.

               +-----------+ +-----------+
               | Scintilla | | Notepad++ |
               +-----------+ +-----------+
                    ^             ^
                    |             |
           +--------+--------+----+------------+                   
           |                 |                 |
 +------------------+ +----------------+ +-----------+ 
 | ScintillaGateway | | NotepadGateway | | Win32     |
 +------------------+ +----------------+ +-----------+ 
      ^                     ^                ^        
      |                     |                |        
      +-----------------+---+----------------+                   
                        |              
                   +-----------+ 
                   | Plugin    |
                   +-----------+ 

How to debug plugins

  • Install both 32 bit and 64 bit versions of Notepad++ (if you intend to publish for both)
  • Give yourself write permissions to the Notepad++ plugin folders
    • Usually C:\Program Files (x86)\Notepad++\plugins\ (for 32 bit) and C:\Program Files\Notepad++\plugins\ (for 64 bit)
    • Or run Visual Studio as administrator (not recommended)
  • In Visual Studio, choose Platform to debug (x86 or x64)
  • Make sure Notepad++ is not running
  • Start Debugging (F5 by default)

Or you can attach to a running process:

  • start notepad++
  • in Visual Studio: debug -> attach to process... -> notepad++.exe

you can now set breakpoints and step-execute. (currently not working in v6.9.2 notepad-plus-plus/notepad-plus-plus#1964)

  • you can make this process easier by setting the "start action" in the project -> properties -> debug to start notepad++.exe - then you can simply build and hit F5.

Working with dependencies

To use external dependencies such as libraries in your plugin you can proceed in two ways:

  • clone the dependency sources into your plugin project (e.g. as a shared project)
  • add the dependency as reference (i.e. via NuGet) and merge it into the plugin .dll via ILMerge (preferred)

Shared Projects

One possibility is to include dependencies by adding the required source code into a new Shared Project in the plugin-development solution.

Assuming you are using Visual Studio to add a Shared Project to your solution (New Project -> Shared Project) and copy the required sources into that project. Double-check that the Shared Project is part of your main plugin-project references. If not, add the reference. You are now ready to use the included sources in your plugin and they will be compiled into the final plugin .dll.

Note: Do not include properties etc. from other dependencies when copying the sources, as the main project defines the e.g. assembly information.

References

The prefered way to use dependencies is via References, in the best-case through NuGet.

Via NuGet you are able to add packages to your project, certain versions etc. through a global repository. Package information is stored in your project and other developers can gather the same, correct versions through the global repository without committing masses of data.

To use included references in your compiled plugin you need to merge these into the .dll as Notepad++ is not fond of locating non-plugin .dll's in its folder. ILMerge was developed for the purpose of merging managed libraries. It can be installed via NuGet and used manually.

The best way is to install MSBuild.ILMerge.Task via NuGet in your plugin project. It will include ILMerge as dependency and attach itself to your Visual Studio build process. By that, with every build you compile a merged plugin .dll including all your custom references to use. ILMerge will add configuration files to your project: ILMerge.props and ILMergeOrder.txt. Refer to the official homepage for more information about the configuration possibilities.

Note: To use ILMerge in your plugin you have to change the Target Framework of your plugin project to at least .NET Framework 4.0 (CP). ILMerge can work with .NET 3.5 and below, but requires additional configuration and adaptation. If you do not required the extreme backwards compatibility, upgrade the .NET Framework target as quick and easy solution.

32 vs 64 bit

Notepad++ comes in two versions, 32 bit and 64 bit. Unfortunately this means plugins need to create two versions as well.

Using this template you can switch between the two using the Visual Studio "Target Platform" drop-down.

When publishing your plugin you should build in Release mode for both x86 and x64 and publish both resulting dll's (e.g. bin/Release/myPlugin.dll and /bin/Release-x64/MyPlugin.dll)

Requirements

  • Works with .NET Runtime 4.0 and above
  • UNICODE plugins only.
  • Works on Notepad++ 7.6.3 and above

For Notepad++ 7.6 to 7.6.2 no release works out of the box due to plugin directories changing with every release.

v0.95.00 pre-release

Latest version as of Jan 2021 contains x64 fixes and updated HOW-TO-INSTALL.txt
Tested on VS2019 and latest Notepad++ both x86 and x64 versions.

v0.94.00

The last version to work with Notepad++ v7.5.9 or below (newer versions of notepad++ use a different plugin structure, so you need to use a newer version of this framework). If you copy the binaries to the right place, you may still get things working.

v0.93.96

The last known version to run vs2015 is v0.93.96 (https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net/releases) with a little fidling you may be able to get newer versions to run 2015 as well. I just haven't tested it.

Versioning

Until we reach v1.0 expect a bit of chaos and breaking changes.

From v1.0 and onwards we will turn over to semantic versioning

Credits

And of course the people helping out with pull requests! Much appreciated!

About me

I blog at http://firstclassthoughts.co.uk/ on code readability and quality

Notes

notepadpluspluspluginpack.net's People

Contributors

alex-ilin avatar annavel avatar bdr76 avatar chcg avatar dail8859 avatar fruchtzwerg94 avatar gandarez avatar jokedst avatar kbilsted avatar lipnitsk avatar mahee96 avatar molsonkiko avatar oleg-shilo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

notepadpluspluspluginpack.net's Issues

ScNotification.TextPointer points to nothing in 64bit

I tried using the SCN_AUTOCSELECTION notification to insert something else than what was selected in the autocomplete menu.

The pointer to the text of the selected option should be in notification.TextPointer. But when run in 64bit, it points to nothing, and notification.Length contains some large negative number.

image

The problem seems to be that the type of position that appears ahead of TextPointer in the ScNotification struct is of the wrong type.

In the plugin template it's an int, while in the sourcecode of scintilla it's defined as a Sci_Position which is a ptrdiff_t.
image

So I think that needs to change from int to IntPtr (and if I try and test that, it does seem to work for both 32 and 64 bit).

There seems to be a few more fields (mentioned by dinkumoil in the topic linked below) that have changed from int to ptrdiff_t, so you'll probably need to change more than just position:
https://community.notepad-plus-plus.org/topic/17755/notepad-7-7-breaking-change-of-scnotification-definition-in-x64-build

Here is a small project to demonstrate the issue (run it, use the Plugins > MyNppPluginAutoC > MyMenuCommand, an autocomplete menu should appear, select something, and a messagebox should show what was selected, then try again in 64bit):
MyNppPluginAutoC.zip

X64 pointer arithmetic issue

See https://notepad-plus-plus.org/community/topic/12633/npppluginnet-64-bit.

Issue is caused by problematic pointer arithmetic in

public void Add(FuncItem funcItem)

and

public void RefreshItems()

in class FuncItems in NppPluginNETHelper.cs, like:

    IntPtr ptrPosNewItem = (IntPtr)((int)newPointer + oldSize);

So the cast to int from type IntPtr shortens the pointer for X64, see e.g.

https://blogs.msdn.microsoft.com/jaredpar/2008/11/11/properly-incrementing-an-intptr/
or
https://stackoverflow.com/questions/1866236/add-offset-to-intptr

Code generate notepad++ constants and helper methods

Possible data corruption(Plugin Failure) in x64 environment due to usage of int where intptr_t should have been used

Based on Scintilla the type 'intptr_t' in the Scintilla.iface file is based on the execution-image-memory-model dependent ie: it will be 32bits in x86 env whereas 64-bits in x64 env.

Hence scintilla docs suggests to use "intptr_t" type which is a pointer container that actually is size allocated based on the execution memory model for user-defined types such as Sci_Position, uptr_t, sptr_t.

If we take that into fact, then the x64 plugins using the .NET 'int'(standard 32-bit irrespective of memory model) would be losing data if an overflow occurs.

This is can be observed as below:

// interface declaration: IScintillaGateway in ScintillaGateway.cs
int GetCurrentLineNumber();

// class which implements the interface: ScintillaGateway: IScintillaGateway  in ScintillaGateway.cs
public int GetCurrentLineNumber()
        {
            return LineFromPosition(GetCurrentPos());
        }

public int GetCurrentPos()
        {
            return (int)Win32.SendMessage(scintilla, SciMsg.SCI_GETCURRENTPOS, (IntPtr) Unused, (IntPtr) Unused);
        }

public int LineFromPosition(int pos)
        {
            return (int)Win32.SendMessage(scintilla, SciMsg.SCI_LINEFROMPOSITION, (IntPtr) pos, (IntPtr) Unused);
        }

// struct definition for ScNotification in Scintilla_iface.cs
[StructLayout(LayoutKind.Sequential)]
    public struct ScNotification
    {
        public ScNotificationHeader Header;
        private IntPtr position;               /* SCN_STYLENEEDED, SCN_DOUBLECLICK, SCN_MODIFIED, SCN_MARGINCLICK, SCN_NEEDSHOWN, SCN_DWELLSTART, SCN_DWELLEND, SCN_CALLTIPCLICK, SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK, SCN_HOTSPOTRELEASECLICK, SCN_INDICATORCLICK, SCN_INDICATORRELEASE, SCN_USERLISTSELECTION, SCN_AUTOCSELECTION */
        public int character;               /* SCN_CHARADDED, SCN_KEY, SCN_AUTOCCOMPLETE, SCN_AUTOCSELECTION, SCN_USERLISTSELECTION */
        public int Mmodifiers;              /* SCN_KEY, SCN_DOUBLECLICK, SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK, SCN_HOTSPOTRELEASECLICK, SCN_INDICATORCLICK, SCN_INDICATORRELEASE */
        public int ModificationType;        /* SCN_MODIFIED - modification types are name "SC_MOD_*" */
        public IntPtr TextPointer;          /* SCN_MODIFIED, SCN_USERLISTSELECTION, SCN_AUTOCSELECTION, SCN_URIDROPPED */
        public int Length;                  /* SCN_MODIFIED */
        public int LinesAdded;              /* SCN_MODIFIED */
        public int Message;                 /* SCN_MACRORECORD */
        public IntPtr wParam;               /* SCN_MACRORECORD */
        public IntPtr lParam;               /* SCN_MACRORECORD */

        /// <summary>
        /// 0-based index
        /// </summary>
        public int LineNumber;           /* SCN_MODIFIED */
        public int FoldLevelNow;         /* SCN_MODIFIED */
        public int FoldLevelPrev;        /* SCN_MODIFIED */
        public int Margin;               /* SCN_MARGINCLICK */
        public int ListType;             /* SCN_USERLISTSELECTION */
        public int X;                    /* SCN_DWELLSTART, SCN_DWELLEND */
        public int Y;                    /* SCN_DWELLSTART, SCN_DWELLEND */
        public int Token;                /* SCN_MODIFIED with SC_MOD_CONTAINER */
        public int AnnotationLinesAdded; /* SC_MOD_CHANGEANNOTATION */
        public int Updated;              /* SCN_UPDATEUI */
        public int ListCompletionMethod; /* SCN_AUTOCSELECTION, SCN_AUTOCCOMPLETED, SCN_USERLISTSELECTION */

        /// <summary>
        /// SCN_STYLENEEDED, SCN_DOUBLECLICK, SCN_MODIFIED, SCN_MARGINCLICK, SCN_NEEDSHOWN, SCN_DWELLSTART, SCN_DWELLEND, SCN_CALLTIPCLICK, SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK, SCN_HOTSPOTRELEASECLICK, SCN_INDICATORCLICK, SCN_INDICATORRELEASE, SCN_USERLISTSELECTION, SCN_AUTOCSELECTION
        /// </summary>
        public Position Position { get { return new Position(position); } }

        /// <summary>
        /// Character of the notification - eg keydown
        /// SCN_CHARADDED, SCN_KEY, SCN_AUTOCCOMPLETE, SCN_AUTOCSELECTION, SCN_USERLISTSELECTION
        /// </summary>
        public char Character { get { return (char) character; } }
    }

For reference (from) Scintilla.h:

// Definitions of common types
#ifdef _WIN64
    typedef unsigned __int64 size_t;
    typedef __int64          ptrdiff_t;
    typedef __int64          intptr_t;
#else
    typedef unsigned int     size_t;
    typedef int              ptrdiff_t;
    typedef int              intptr_t;
#endif
#ifndef _UINTPTR_T_DEFINED
    #define _UINTPTR_T_DEFINED
    #ifdef _WIN64
        typedef unsigned __int64  uintptr_t;
    #else
        typedef unsigned int uintptr_t;
    #endif
#endif

// Basic signed type used throughout interface
typedef ptrdiff_t Sci_Position;
// Define uptr_t, an unsigned integer type large enough to hold a pointer.
typedef uintptr_t uptr_t;
// Define sptr_t, a signed integer large enough to hold a pointer.
typedef intptr_t sptr_t;

struct Sci_NotifyHeader {
	/* Compatible with Windows NMHDR.
	 * hwndFrom is really an environment specific window handle or pointer
	 * but most clients of Scintilla.h do not have this type visible. */
	void *hwndFrom;
	uptr_t idFrom;
	unsigned int code;
};

struct SCNotification {
	Sci_NotifyHeader nmhdr;
	Sci_Position position;
	/* SCN_STYLENEEDED, SCN_DOUBLECLICK, SCN_MODIFIED, SCN_MARGINCLICK, */
	/* SCN_NEEDSHOWN, SCN_DWELLSTART, SCN_DWELLEND, SCN_CALLTIPCLICK, */
	/* SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK, SCN_HOTSPOTRELEASECLICK, */
	/* SCN_INDICATORCLICK, SCN_INDICATORRELEASE, */
	/* SCN_USERLISTSELECTION, SCN_AUTOCSELECTION */

	int ch;
	/* SCN_CHARADDED, SCN_KEY, SCN_AUTOCCOMPLETED, SCN_AUTOCSELECTION, */
	/* SCN_USERLISTSELECTION */
	int modifiers;
	/* SCN_KEY, SCN_DOUBLECLICK, SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK, */
	/* SCN_HOTSPOTRELEASECLICK, SCN_INDICATORCLICK, SCN_INDICATORRELEASE, */

	int modificationType;	/* SCN_MODIFIED */
	const char *text;
	/* SCN_MODIFIED, SCN_USERLISTSELECTION, SCN_AUTOCSELECTION, SCN_URIDROPPED */

	Sci_Position length;		/* SCN_MODIFIED */
	Sci_Position linesAdded;	/* SCN_MODIFIED */
	int message;	/* SCN_MACRORECORD */
	uptr_t wParam;	/* SCN_MACRORECORD */
	sptr_t lParam;	/* SCN_MACRORECORD */
	Sci_Position line;		/* SCN_MODIFIED */
	int foldLevelNow;	/* SCN_MODIFIED */
	int foldLevelPrev;	/* SCN_MODIFIED */
	int margin;		/* SCN_MARGINCLICK */
	int listType;	/* SCN_USERLISTSELECTION */
	int x;			/* SCN_DWELLSTART, SCN_DWELLEND */
	int y;		/* SCN_DWELLSTART, SCN_DWELLEND */
	int token;		/* SCN_MODIFIED with SC_MOD_CONTAINER */
	Sci_Position annotationLinesAdded;	/* SCN_MODIFIED with SC_MOD_CHANGEANNOTATION */
	int updated;	/* SCN_UPDATEUI */
	int listCompletionMethod;
	/* SCN_AUTOCSELECTION, SCN_AUTOCCOMPLETED, SCN_USERLISTSELECTION, */
	int characterSource;	/* SCN_CHARADDED */
};

which should have been as follows:

// interface declaration: IScintillaGateway in ScintillaGateway.cs
long GetCurrentLineNumber();

// class which implements the interface: ScintillaGateway: IScintillaGateway  in ScintillaGateway.cs
public long GetCurrentLineNumber()
        {
            return LineFromPosition(GetCurrentPos());
        }

public long GetCurrentPos()
        {
            return (long)Win32.SendMessage(scintilla, SciMsg.SCI_GETCURRENTPOS, Unused, Unused);
        }

public long LineFromPosition(long pos)
        {
            return (long)Win32.SendMessage(scintilla, SciMsg.SCI_LINEFROMPOSITION, (IntPtr) pos, Unused);
        }

// struct definition for ScNotification in Scintilla_iface.cs
[StructLayout(LayoutKind.Sequential)]
    public struct ScNotification
    {
        public ScNotificationHeader Header;
        public IntPtr position;              
        public int character;               
        public int Mmodifiers;              /* SCN_KEY, SCN_DOUBLECLICK, SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK, SCN_HOTSPOTRELEASECLICK, SCN_INDICATORCLICK, SCN_INDICATORRELEASE */
        public int ModificationType;        /* SCN_MODIFIED - modification types are name "SC_MOD_*" */
        public IntPtr TextPointer;          /* SCN_MODIFIED, SCN_USERLISTSELECTION, SCN_AUTOCSELECTION, SCN_URIDROPPED */
        public IntPtr Length;                  /* SCN_MODIFIED */
        public IntPtr LinesAdded;              /* SCN_MODIFIED */
        public int Message;                 /* SCN_MACRORECORD */
        public IntPtr wParam;               /* SCN_MACRORECORD */
        public IntPtr lParam;               /* SCN_MACRORECORD */

        public IntPtr Line;           /* SCN_MODIFIED */
        public int FoldLevelNow;         /* SCN_MODIFIED */
        public int FoldLevelPrev;        /* SCN_MODIFIED */
        public int Margin;               /* SCN_MARGINCLICK */
        public int ListType;             /* SCN_USERLISTSELECTION */
        public int X;                    /* SCN_DWELLSTART, SCN_DWELLEND */
        public int Y;                    /* SCN_DWELLSTART, SCN_DWELLEND */
        public int Token;                /* SCN_MODIFIED with SC_MOD_CONTAINER */
        public IntPtr AnnotationLinesAdded; /* SC_MOD_CHANGEANNOTATION */
        public int Updated;              /* SCN_UPDATEUI */
        public int ListCompletionMethod; /* SCN_AUTOCSELECTION, SCN_AUTOCCOMPLETED, SCN_USERLISTSELECTION */
        public int characterSource;	/* SCN_CHARADDED */
        
        /// <summary>
        /// SCN_STYLENEEDED, SCN_DOUBLECLICK, SCN_MODIFIED, SCN_MARGINCLICK, SCN_NEEDSHOWN, SCN_DWELLSTART, SCN_DWELLEND, SCN_CALLTIPCLICK, SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK, SCN_HOTSPOTRELEASECLICK, SCN_INDICATORCLICK, SCN_INDICATORRELEASE, SCN_USERLISTSELECTION, SCN_AUTOCSELECTION
        /// </summary>
        public Position Position { get { return new Position(position); } }

        /// <summary>
        /// Character of the notification - eg keydown
        /// SCN_CHARADDED, SCN_KEY, SCN_AUTOCCOMPLETE, SCN_AUTOCSELECTION, SCN_USERLISTSELECTION
        /// </summary>
        public char Character { get { return (char)character; } }
    }

@kbilsted look at the updated version, the long maintains the data to be 64-bit wide so that the data whatsoever it may be, 32bits or 64-bits contained in the IntPtr being returned from the SendMessage Win32k Api call to C++ application.

This should also take care of the arithmetic/logical operation issues which would ensue if using the IntPtr in function/method signatures instead of long.

The "long" would waste 32-bits of storage for each allocation because in 32-bit environment the returned data from IntPtr would be of size "int", but will save us from hassle of the above mentioned issues with operators with a slight cost to storage.

Note: However the underlying mapping "structure of the ScNotification struct, needs to use IntPtr since, the data alignment should match the data coming from C++ code.

SetCommand() has unneeded parameter

SetCommand() currently takes an index as its first parameter. It uses this to set the _cmdID field. However, this is a field N++ sets internally. All of my C++ plugins just set the initial value of _cmdID to 0 and it has always worked fine. Since removing that parameter would break backwards compatibilty with older versions of the plugin pack you may want to wait till a "stable" 1.0 release or just do it now since it is very easy for developers to make the change.

Something else to note, there are cases where you need to store the index, like this example. Instead of making the developer manually count what index it is getting inserted at, you can make SetCommand() return the newly added index, so that the example I referenced will look like this:

idMyDlg = PluginBase.SetCommand("MyDockableDialog", myDockableDialog);

Plugin via template not run in npp

Hello,

I installed the template, but can't get the plugin to run inside NPP. I use the current Windows 10 x64 Pro version with NPP x86 (v7.6.2). The plugin (as generated by the template without any adjustments) is built correctly under %PROGRAMDATA%\Notepad++\plugins\. However, it is neither displayed in the plugin admin nor the commands anywhere else within NPP.
Best regards

P.S: The same behaviour with the x64 version of npp

Location of plugin dll in Notepad++ after build not in appropriate location

NPP Version 7.7.1 (64-bit)
If I create a new project called XXX and build, it will put a dll in C:\Program Files\Notepad++\plugins called XXX.dll

In this version of NPP the dll needs to go in a folder of the exact same name so in this location: C:\Program Files\Notepad++\plugins\XXX\XXX.dll


To get around this for now in C:\Program Files\Notepad++\plugins I created a folder with the same name as my dll (in the above example XXX)
then I edited the file in my project called NppPlugin.DllExport.targets from this...
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(ProgramW6432)\Notepad++\plugins\" Condition="Exists('$(ProgramW6432)\Notepad++\plugins\') AND '$(Platform)'=='x64'" ContinueOnError="false" />

to...
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(ProgramW6432)\Notepad++\plugins\$(ProjectName)\" Condition="Exists('$(ProgramW6432)\Notepad++\plugins\$(ProjectName)\') AND '$(Platform)'=='x64'" ContinueOnError="false" />

this is only a temporary fix. The build would need to create the folder if it did not exist

Link to forum discussion: https://stackoverflow.com/questions/40015350/how-to-install-a-notepad-plugin-offline

Create an editor gateway

Create a primary interface for plugin-writers to Notepad++/Scintilla.

changes must be done on branch topic/editorgateway_v1

I: Visual Studio 2017 change of compiler tools directory layout

Hey @kbilsted

I just had to reinstall my machine and with it I updated/installed the newest Visual Studio version 2017. Unfortunately, they made a bigger change in the folder structure. You can read more about it here https://blogs.msdn.microsoft.com/vcblog/2016/10/07/compiler-tools-layout-in-visual-studio-15/

By that, the DllExportTask property

LibToolPath="$(DevEnvDir)\..\..\VC\bin"

won't work anymore, as the Dev Environment changed.

I circumvented this for now by importing the current tools version props

<Import Condition="Exists('$(DevEnvDir)\..\..\VC\Auxiliary\Build')" Project="$(DevEnvDir)\..\..\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.props" />  

and set the LibToolPath to

LibToolPath="$(DevEnvDir)\..\..\VC\Tools\MSVC\$(VCToolsVersion)\bin\Host$(Platform)\$(Platform)"

You may checkout https://github.com/nea/MarkdownViewerPlusPlus/blob/master/MarkdownViewerPlusPlus/MarkdownViewerPlusPlus.csproj#L280.

I am not 100% convinced by what I did, especially with the host platform... but it works for now ^^' If something like that with 2017 comes up on your end.

Cheers

Demo plugin a bit too trivial, add edit text demo?

This is an excellent template but the demo plugin is a bit too trivial imho. I mean a plug-in would typically do something with the current opened text file.

So instead of a line-jump demo, maybe also add word find and replace demo. So two textboxes and a button to replace one with the other, for example "Cat" and "Kitten" or something like that?

Copy the dll in the plugin subdirectory

Hello,

I followed the steps to install and build your C# NppPlugin package. All went fine, except that the plugin was not showing in the plugin menu, nor the plugin icon in the toolbar. I found the dll had been copied directly in the plugins directory of Notepad++. I also noticed that the dlls of all the other plugins were placed in their own subdirectories. So I created a directory (in the plugins directory of Notepad++) that I named with the plugin's name, and I put the dll in this new directory. I restarted Notepad++ and the plugin was present in the plugins menu and worked as expected.

Now I would like to be able to tell Visual Studio to copy the dll in that subdirectory, so that I don't have to do it manually after each build. I looked in project properties > build and > post-build events, but I found nothing set about copying the dll elsewhere than in the VS project output directory (in my case: bin\Debug-x64)...

-- Using NppPlugin0.94.00.zip, Visual Studio 2017 (target Framework: .Net Framework 4, platform target: x64), and Notepad++ v7.6.3 64-bit (which moved "plugins home from %ProgramData% to %ProgramFiles% for the sake of security").

Any help appreciated.

PropertyGrid dropdown list not showing up

Steps:

  1. Add a a PropertyGrid control in demo project frmGoToLine

  2. Add a new class inside of frmGoToLine
    ` class Test
    {
    public string Name { get; set; }

         public bool IsTrue { get; set; }
    
         public Color Color { get; set; }
    
         public Font Font { get; set; }
     }`
    
  3. Add propertyGrid1.SelectedObject = new Test(); in frmGoToLine constructor

Color, Boolean dropdown list not showing up but FontDialog pops up.

Document how to use external dependencies in plugins

A brief description of how to do this in the README.MD.

so far what works

  • clone the dependency directly into your project so it is compiled along with your code
  • use ILMerge (perhaps also a reference to a working project using this strategy)

VS2019 requirements - still dependant on .Net 3.5

With a new project created using NppPlugin0.94.00.zip, using VS2019, the build failed with "Could not load file or assembly 'Microsoft.Build.Utilities, Version=2.0.0.0". I had installed the workload "Desktop development with C++", but this does not provide the required build tools or expected version.

Has anybody created a guide for getting this to build in VS2019?

Build problems

Hello Kasper,

This is a slightly modified copy of the issue first posted here.

I have not made any progress on understanding the issues. When I have a better understanding of how to use the plugin pack I would be happy to make some improvements to the ReadMe etc.

Thank you for creating the new plugin pack. Unfortunately I am having some challenges in using it and I would welcome your comments on what I am doing wrong.

First a minor observation on the installation notes. In the "README.md" file at section “Getting started” 2: When we copy the NppPlugin[version].zip file should we keep the version number in the file name or should we rename it to NppPlugin.zip? I just copied the file and kept the version number, that seemed to work.

I created a new project using the template. It defaults to .NET 3.5.2 which is not on my computer, so I changed the project to target 4.6.1.

Tried to build the project without making any changes and without adding any of the code of my plugin. Get two errors:

1>[[...]]\Main.cs(19,31,19,41): error CS0103: The name 'Properties' does not exist in the current context
1>[[...]]\Main.cs(20,37,20,47): error CS0103: The name 'Properties' does not exist in the current context

against these two lines:

    static Bitmap tbBmp = Properties.Resources.star;
    static Bitmap tbBmp_tbTab = Properties.Resources.star_bmp;

File “Main.cs” has the line “namespace Kbg.NppPluginNET” (for class Main). Comparing to the Demo project, file “Demo.cs” has the line “namespace Kbg.Demo.Namespace” and in the demo project file “Resources.Designer.cs” has the line “namespace Kbg.Demo.Namespace.Properties”.

In my project I changed the namespace names in files “UnmanagedExports.cs” and “Resources.Designer.cs” to match my project. Also I added a “using Kbg.NppPluginNET;” to file “Main.cs” so that “frmMyDlg” in the line “static frmMyDlg frmMyDlg = null;” is available.

It would be useful if the installation notes could give some guidance on which files and classes should use which namespaces.

Building the solution gives the error (was all on one line, so manually wrapped):

1>[[...]]\PluginInfrastructure\DllExport\NppPlugin.DllExport.targets(8,5): error MSB4062:
The "NppPlugin.DllExport.MSBuild.DllExportTask" task could not be loaded from the assembly [[...]]\PluginInfrastructure\DllExport\NppPlugin.DllExport.MSBuild.dll.
Could not load file or assembly 'Microsoft.Build.Utilities, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
The system cannot find the file specified.
Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

I find this message from Visual Studio very confusing. The text “UsingTask” does not seem to be in any of the files in the solution, nor can I find “Microsoft.Build.Utilities” or “ITask”.

Next I installed .NET 3.5.2 and then the build does not report the above error. Now the build fail with the message:

1>AfterBuild:
1>  Cannot find lib.exe in 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\\..\..\VC\bin'.

There is no “lib.exe” in any of the sub-directories of “Microsoft Visual Studio 14.0” on my computer, but there are versions in the correct sub-directories of both “Microsoft Visual Studio 11.0” and “Microsoft Visual Studio 12.0”.

I also tried building the demo project and it also fails to find “lib.exe”.

Environment is Windows 10 with Microsoft Visual Studio Enterprise 2015 Version 14.0.25123.00 Update 2.

Regards
Adrian

arithmetic overflow listing all open files with ClikeStringArray

From my plugin I'm trying to list all open files. This has been working ok in 32 bit world or a couple of years, but my 64 bit version (in Visual Studio 2017) gets an error:

The code:

        static void getFileNamesDemo() {
            int nbFile = (int)Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETNBOPENFILES, 0, 0);
            MessageBox.Show(nbFile.ToString(), "Number of opened files:");

            using (ClikeStringArray cStrArray = new ClikeStringArray(nbFile, Win32.MAX_PATH)) {
                if (Win32.SendMessage(PluginBase.nppData._nppHandle, (uint)NppMsg.NPPM_GETOPENFILENAMES, cStrArray.NativePointer, nbFile) != IntPtr.Zero)
                    foreach (string file in cStrArray.ManagedStringsUnicode) MessageBox.Show(file);
            }
        }

fails inside

public ClikeStringArray(int num, int stringCapacity)

on the line

Marshal.WriteIntPtr((IntPtr)((int)_nativeArray + (i * IntPtr.Size)), item);

saying

System.OverflowException: Arithmetic operation resulted in an overflow.
at System.intPtr.op_Explicit(IntPtr value) at
Kbg.NppPluginNET.PluginInfrastructure.ClikeStringArray..ctor(Int32 num, Int32 stringCapacity)

ScintillaGateway GetText truncate

Hi,

I've got a problem with the GetText(int length) method in the ScintillaGateway.
I wish to get a big text (around 15kb or even more), in that case the result is truncated at 10kb.
This is because of the textBuffer size.
Is it possible to replace original code :
byte[] textBuffer = new byte[10000];
with
byte[] textBuffer = new byte[length];

Thank you

Timop

Access violation in x64 builds of latest Notepad++ release

In the 8.3 release of Notepad++, the type of Scintilla's Sci_PositionCR message changed from long to intptr_t. As a result, 64-bit plugins using the NppPlugin.NET interface are prone to access violations when calling into the SCI_GETTEXTRANGE API.

After seeing this analysis of recent crashes involving the CsvQuery and DSpellCheck plugins, I was able to reproduce with CS-Script (1.7.26) — which, like CsvQuery, is compiled with NppPlugin.NET (0.93.96). The event log recorded a stack trace with ScintillaGateway.GetTextRange near the top:

<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name=".NET Runtime" />
    <EventID Qualifiers="0">1026</EventID>
    <Version>0</Version>
    <Level>2</Level>
    <Task>0</Task>
    <Opcode>0</Opcode>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2022-02-06T20:37:13.4781435Z" />
    <EventRecordID>20975</EventRecordID>
    <Correlation />
    <Execution ProcessID="9132" ThreadID="0" />
    <Channel>Application</Channel>
    <Computer>AcerNotebook</Computer>
    <Security />
  </System>
  <EventData>
    <Data>Application: notepad++.exe
    Framework Version: v4.0.30319
    Description: The process was terminated due to an unhandled exception.
    Exception Info: exception code c0000005, exception address 00007FF6BE92EFFF
    Stack:
    at Kbg.NppPluginNET.PluginInfrastructure.Win32.SendMessage(IntPtr, UInt32, IntPtr, IntPtr)
    at Kbg.NppPluginNET.PluginInfrastructure.Win32.SendMessage(IntPtr, UInt32, IntPtr, IntPtr)
    at Kbg.NppPluginNET.PluginInfrastructure.ScintillaGateway.GetTextRange(Kbg.NppPluginNET.PluginInfrastructure.TextRange)
    at CSScriptIntellisense.NppExtensions.GetTextBetween(Kbg.NppPluginNET.PluginInfrastructure.ScintillaGateway, Int32, Int32)
    at CSScriptNpp.CodeMapPanel.RefreshContent()
    at CSScriptNpp.Plugin.OnCurrentFileChanged()
    at CSScriptNpp.UnmanagedExports.beNotified(IntPtr)
    at Kbg.NppPluginNET.UnmanagedExports.beNotified(IntPtr)
    at Kbg.NppPluginNET.PluginInfrastructure.Win32.SendMessage(IntPtr, UInt32, IntPtr, System.String)
    at Kbg.NppPluginNET.PluginInfrastructure.Win32.SendMessage(IntPtr, UInt32, IntPtr, System.String)
    at CSScriptNpp.ProjectPanel.newBtn_Click(System.Object, System.EventArgs)
    at System.Windows.Forms.ToolStripItem.RaiseEvent(System.Object, System.EventArgs)
    at System.Windows.Forms.ToolStripButton.OnClick(System.EventArgs)
    at System.Windows.Forms.ToolStripItem.HandleClick(System.EventArgs)
    at System.Windows.Forms.ToolStripItem.HandleMouseUp(System.Windows.Forms.MouseEventArgs)
    at System.Windows.Forms.ToolStrip.OnMouseUp(System.Windows.Forms.MouseEventArgs)
    at System.Windows.Forms.Control.WmMouseUp(System.Windows.Forms.Message ByRef, System.Windows.Forms.MouseButtons, Int32)
    at System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message ByRef)
    at System.Windows.Forms.ToolStrip.WndProc(System.Windows.Forms.Message ByRef)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr, Int32, IntPtr, IntPtr)</Data>
  </EventData>
</Event>

For reference, both the CharacterRange and TextRange interface wrapper types have constructors taking ints:

  [StructLayout(LayoutKind.Sequential)]
  public struct CharacterRange
  {
      public CharacterRange(int cpmin, int cpmax) { cpMin = cpmin; cpMax = cpmax; }
      public int cpMin;
      public int cpMax;
  }
  public TextRange(CharacterRange chrRange, int stringCapacity)
  {
      _sciTextRange.chrg = chrRange;
      _sciTextRange.lpstrText = Marshal.AllocHGlobal(stringCapacity);
  }
  public TextRange(int cpmin, int cpmax, int stringCapacity)
  {
      _sciTextRange.chrg.cpMin = cpmin;
      _sciTextRange.chrg.cpMax = cpmax;
      _sciTextRange.lpstrText = Marshal.AllocHGlobal(stringCapacity);
  }

Related to:

See also:

bug in python generator for scintilla.iface

@dail8859 script for autogenerating C# fails for the variable

INVALID_POSITION = -1,

uint cannot have the value of -1 - I've manually changed the value to the old value

    INVALID_POSITION = 0xFFFFFFFF,

but the script has yet to be fixed

make code generated code stand out more

by accident we merged PR that change the code generated code. The code should be heavily commented with it being code generated and should not be touched

prevent regression

the latest bugfix changes (prior to @mahee96 ) were made directly in the generated code rather than i the code generator - it needs be moved to the code generator

ensure that changes are not lost - but perhaps @mahee96 lastest changes incorporate it all

in x64 ScNotification.character is always '\0'

Hi ,
many thanks for your great work!! May I report one issue in x64 environment?

In my plugin I do not want to perform any actions when the user pressed space key. Therefore I want to know which key the user pressed and use this logic

`public static void OnNotification(ScNotification notification) {
...
if (notification.Header.Code == (uint)SciMsg.SCN_CHARADDED{
Char c = notification.Character;
if (!c.Equals(' ') {
// do some actions
}

`
Debugging showed me that c contains '\0' instead of a space when the user pressed the Space Key.
I can probably find some work-around but I wanted to give something back to the community but could not find a solution for this.
Maybe someone can help me. I am happy to support.
Please note that this issue is not happening in x86 environment
Regards
GM

win32 api extension

In 04639eb I've added

[DllImport("user32")]
public static extern IntPtr SendMessage(IntPtr hWnd, SciMsg Msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32")]
public static extern IntPtr SendMessage(IntPtr hWnd, SciMsg Msg, IntPtr wParam, int lParam);

not sure if it works - but was required for making my code generation work (as it uses only utf-8 strings). A quick search in the notepad++ project did not reveal whether this is ok or not. I'm prefering this way over using the overloads taking a StringBuilder as I use a byte[] and Encoding.UTF8 to proper encode/decode strings.

@ufo perhaps you have valuable input in this matter?

Q: Adding 3rd Party Libs via NuGet and using them

Hi there

First of all: Thanks a lot for this template! Getting it to work was simple and as expected. Thanks for that.

But I have a question regarding the addition of other 3rd Party Libraries: Do these have to be "prepared" to be usable as extended plugin library? Or do these have to be added in some way I am missing, when referenced via NuGet?

Just for example: https://github.com/Knagis/CommonMark.NET
Using it results in instant errors. Calling static string/text variables is no problem, so I think it is available. But using it results in errors I cannot event catch, and as I used it for testing purposes in the notification method, Notepad++ doesn't even boot but crashes with a dialog without much info, just the message.

Thanks a lot in advance for any help and sorry if this question is too primitive ^^#

Is this repository abandoned by kbilsted?

kbilsted hasn't done anything in this repo since 20 Jan 2018. I'm starting to think he abandoned this project.

I'd be willing to step in as contributor if he allows it, in order to merge some PRs.
Otherwise I fear the only way to move forward is to fork the project.

Since kbilsted is active on github he'll probably see this. Any thoughts?

Export Failed?

[DllExport(CallingConvention=CallingConvention.Cdecl)]
        static bool isUnicode()
        {
            return true;
        }

        [DllExport(CallingConvention = CallingConvention.Cdecl)]
        static void setInfo(NppData notepadPlusData)
        {
            PluginBase.nppData = notepadPlusData;
            Main.CommandMenuInit();
        }

        [DllExport(CallingConvention = CallingConvention.Cdecl)]
        static IntPtr getFuncsArray(ref int nbF)
        {
            nbF = PluginBase._funcItems.Items.Count;
            return PluginBase._funcItems.NativePointer;
        }

        [DllExport(CallingConvention = CallingConvention.Cdecl)]
        static uint messageProc(uint Message, IntPtr wParam, IntPtr lParam)
        {
            return 1;
        }

        static IntPtr _ptrPluginName = IntPtr.Zero;
        [DllExport(CallingConvention = CallingConvention.Cdecl)]
        static IntPtr getName()
        {
            if (_ptrPluginName == IntPtr.Zero)
                _ptrPluginName = Marshal.StringToHGlobalUni(Main.PluginName);
            return _ptrPluginName;
        }

        [DllExport(CallingConvention = CallingConvention.Cdecl)]
        static void beNotified(IntPtr notifyCode)
        {
            SCNotification nc = (SCNotification)Marshal.PtrToStructure(notifyCode, typeof(SCNotification));
            if (nc.nmhdr.code == (uint)NppMsg.NPPN_TBMODIFICATION)
            {
                PluginBase._funcItems.RefreshItems();
                Main.SetToolBarIcon();
            }
            else if (nc.nmhdr.code == (uint)NppMsg.NPPN_SHUTDOWN)
            {
                Main.PluginCleanUp();
                Marshal.FreeHGlobal(_ptrPluginName);
            }
        }
>dumpbin -exports MyNppPlugin1.dll
Microsoft (R) COFF/PE Dumper Version 14.00.23918.0
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file MyNppPlugin1.dll

File Type: DLL

  Section contains the following exports for \MyNppPlugin1.dll

    00000000 characteristics
    57314652 time date stamp Tue May 10 10:24:18 2016
        0.00 version
           0 ordinal base
           3 number of functions
           3 number of names

    ordinal hint RVA      name

          2    0 000125AE getFuncsArray
          4    1 CFFFE303 getName
          0    2 0001259E isUnicode

  Summary

        2000 .reloc
        2000 .rsrc
        2000 .sdata
       12000 .text

Visual Studio 2015 windows10

I erroneous operation yet ?

Develop Integrationtest plugin

We need to develop a plugin that will carry out integrationtest of the functionality provided by the framework. We should start out with something simple and gradually make it nicer.

Q: Extending it to be usable as a lexer template

I am currently trying to add a lexer class to the plugin pack so that it can be used to write lexers in C#.
The additional exports needed have been added in UnmanagedExports.cs.
The problem I face is that the methods in the ILexer class are garbage collected.
But from what I have read, static classes or static members of a class should not be garbage collected.
Any idea? Sorry, I am very new to C#.
Btw. My current declaration of the class is different from what is available on github and looks like this.

internal static class ILexer

demo.dll does not work with Notepad++ 7.9.5

Visual Studio 2019,
Notepad++ 7.9.5 source code
NotepadPlusPlusPluginPack.Net, current version

after compile Notepad++ 7.9.5, it works with plugin [markdownviwerplusplus] bin file which is download from Github.
after compile [markdonwviewerplusplus], it does not work with Notepoad++ 7.9.5. reports plugin dll not compatible.
after compile [NotepadPlusPlusPluginPack.Net], it does not work with Notepad++ 7.9.5, reports plugin dll not compatible.

check into plugin dll with a dllexport application, only find export functions [isUnicode] and [getFuncsArray]; no other export functions.

check into [markdownviewerplusplus.dll] which downloaded from github, all export functions are listed.

Please help me, advise me of any extra setup for Visual Studio 2019 needed to correct the issue.

210613215956
210613220134
210616015012
210616015311

thanks,

Build FAILED (Done executing task "DllExportTask" -- FAILED.)

Excuse me. I got the problem of build, how can I solve it?
I follow the "Getting started" that from the README.md and create a new notepad++ template project.
finally, I just build this project but got the problem below.

1> ILAsm: calling 'D:\Tool\Visual Studio 2015\VC\bin\Lib.exe' with "/def:D:\SourceCode\C#\IntelHexViewer\IntelHexViewer\bin\Debug\IntelHexViewer.X86.def" /machine:X86 "/out:D:\SourceCode\C#\IntelHexViewer\IntelHexViewer\bin\Debug\IntelHexViewer.lib" (TaskId:42)
1> ILAsm: Lib 'D:\Tool\Visual Studio 2015\VC\bin\Lib.exe' returned gracefully. (TaskId:42)
1>D:\SourceCode\C#\IntelHexViewer\IntelHexViewer\PluginInfrastructure\DllExport\NppPlugin.DllExport.targets(8,5): error :
1> at NppPlugin.DllExport.Parsing.IlParser.RunILTool(String installPath, String toolFileName, String requiredPaths, String workingDirectory, String settingsName, String arguments, String toolLoggingCode, String verboseLoggingCode, DllExportNotifier notifier, Int32 timeout)
1> at NppPlugin.DllExport.Parsing.ILAsm.RunLibTool(CpuPlatform cpu, String directory, String defFileName)
1> at NppPlugin.DllExport.Parsing.ILAsm.RunCore(CpuPlatform cpu, String fileName, String ressourceParam, String ilSuffix)
1> at NppPlugin.DllExport.Parsing.ILAsm.Run(String outputFile, String ilSuffix, CpuPlatform cpu)
1> at NppPlugin.DllExport.Parsing.ILAsm.ReassembleFile(String outputFile, String ilSuffix, CpuPlatform cpu)
1> at NppPlugin.DllExport.DllExportWeaver.RunILAsm(ILAsm ilAsm)
1> at NppPlugin.DllExport.DllExportWeaver.Run()
1> at NppPlugin.DllExport.MSBuild.DllExportTask.Execute() (TaskId:42)
1>Done executing task "DllExportTask" -- FAILED. (TaskId:42)

minimum requred version of n++

we state

Works on Notepad++ 7.6.3 and above
For Notepad++ 7.6 to 7.6.2 no release works out of the box due to plugin directories changing with every release.

is this still the case after @mahee96 upgrade? investigate and possibly bump required n++ to newer.. or maybe we don't care and simply bump! :)

the color is error?

 public int Value
 {
        get { return Red + (Blue << 8 ) + (Green << 16); } // R G B   ?
 }

NPPN_DOCORDERCHANGED has wrong value

NPPN_DOCORDERCHANGED is defined incorrectly. It is an old bug from the original template. You might take a look at this plugin (this is where I first caught this bug) because this author has updated the C# code quite a bit that may be useful for this template.

Plugin got crashed while opening Notepad++

I am currently using Visual Studio 2010. I build the project and copied the dll file thus created in notepad++ plugin folder.
While opening the notepad++ , I got the below message

Plugin.dll just crashed in notify(SCNotification *notification):

notification ->nmhdr.code == 1002
notification ->nmhdr.hwndForm == 0000000000006A073C
notification ->nmhdr.idForm == 0

Please help to resolve this.

Building new project from template, error "task could not be loaded from the assembly .. NppPlugin.DllExport.MSBuild.dll"

Recently I got a clean Windows 10 installation and I reinstalled Visual Studio. I downloaded the latest version of the template. I put the NppPlugin0.95.00.zip file in the template directory, and create a new project. However then I get this error when I build the project created from the template.

1>Done building target "CoreBuild" in project "MyNppPlugin1.csproj".: (TargetId:78)
1>Target "GetFrameworkPaths" skipped. Previously built successfully.
1>Target "AfterBuild: (TargetId:79)" in file "C:\Users\BdR\source\repos\MyNppPlugin1\MyNppPlugin1\PluginInfrastructure\DllExport\NppPlugin.DllExport.targets" from project "C:\Users\BdR\source\repos\MyNppPlugin1\MyNppPlugin1\MyNppPlugin1.csproj" (target "Build" depends on it):
1>C:\Users\BdR\source\repos\MyNppPlugin1\MyNppPlugin1\PluginInfrastructure\DllExport\NppPlugin.DllExport.targets(13,5): error MSB4062: The "NppPlugin.DllExport.MSBuild.DllExportTask" task could not be loaded from the assembly C:\Users\BdR\source\repos\MyNppPlugin1\MyNppPlugin1\PluginInfrastructure\DllExport\NppPlugin.DllExport.MSBuild.dll. Could not load file or assembly 'Microsoft.Build.Utilities, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Het systeem kan het opgegeven bestand niet vinden. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
1>Done building target "AfterBuild" in project "MyNppPlugin1.csproj" -- FAILED.: (TargetId:79)

I've also checked this issue but there's only a mention that the latest template should work.

Do I have to install .NET 3.5? (seems unlikely because that's an older verion, plus the other issue mentions that should not be necessary)
Is it correct that the NppPlugin.DllExport.MSBuild.dll file is from may 2016 (see here)?
Or do I have to manually rebuild the NppPlugin.DllExport.MSBuild.dll, and if so how?

Cannot get C# plugins to run with x64 NPP for anything newer than Windows 7 x64 OS

I've tried the older c# template and the newer and cannot get to run on Windows 8.1 or Windows 10 using x64 bit version of NPP. Has anyone had luck with this and if so where can I get the template? They work for x64 on Windows 7 and x86 on all OS's. I get plugin dll won't load with current version of NPP message at NPP launch. Any thoughts?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.