AndrewDavid Posted September 7, 2021 Share Posted September 7, 2021 (edited) @Ego Eram Reputo In my thirst for knowledge, I came across this old thread that provides a walkthrough using VS to create a plugin. https://forums.getpaint.net/topic/25828-help-needed-using-visual-studio-instead-of-codelab-for-developing/ If you can believe it - your template still works in Visual Studio 2022 Preview. I took the liberty of editing the walkthrough to reflect the changes since VS Express. I am also able to describe some of the headaches I have been having on my learning curve. Perhaps we can rebuild this thread with tips on how to use VS 2022 Preview to build plugins. Here is the (edited) version of your walkthrough with my comments and questions added. Spoiler Setting the template up 1. Download VS template below (I've updated the references and added some notes). 2. Move the template to the correct directory (e.g. C:\Users\Andrew\Documents\Visual Studio 2022\Templates\ProjectTemplates\). Don't unzip it (as per the original instructions). Customizing the setup - just for your plugin 3. Open VS (I'm using Visual Studio 2022 Preview in order to use net 5.0). 4. Select Create New Project from the right hand pane. 5. Select the Plugin Template - updated Dec2010 with a single click. (Enter 2010 in search box to locate). Click next 6. Type in your plugin name. This is important as the plugin namespace is derived from the project name. Just save yourself the grief. 7. Click create to open the template which will automatically name some aspects for you. 8. Save the project immediately. File > Save "Project Name". 9. Right Click Project name and select properties. Application tab appears. 10. Change Target Framework to .NET 4.8 (not 3.5 Client Profile). A message will come up saying the current project needs to be closed. Select Yes. (At this point I wonder why I don't get to select Net 5.0) When I create a new project I have that option so I know it is installed. Right click on Project and select unload. Double click to open *.csproj file. This is where I have questions about changing the version references to all the old code. For now I will just continue with the walkthrough. 11. Save again then close the solution and reopen. This is usually required when the framework is changed. Best just to do it. 12. Double click the Resources entry in the Solution Explorer. Right click on .png file and select open with. A popup will appear asking to open with. You may have to add paintdotnet.exe to your list of choices. The one supplied is the one I used for WhichSymbol+. 13. Save finished icon & return to VS. 14. Open EffectPlugin.cs by double clicking it in Solution Explorer. 15. Find phrase "Plugin name here" and insert your plugin name. Quotes are required. VS finds one error. Line 143 My solution - Add Reference System.Drawing.Common, version5.0 / This creates another error on line 30 My solution remove System.Drawing / this creates three more errors Line 9, 53,55 and 59. Closed and reopened back to the one error. Proper fix required. Code that is in error; : base(EffectPlugin.StaticName, EffectPlugin.StaticImage, EffectPlugin.StaticSubMenuName, EffectFlags.Configurable) 16. Set the menu that the plugin should appear in. Some samples are included to get you started. I'd generally use the SubmenuNames.Render option rather than the return null option. Render sub-menu name is used as an example. 17. Return to the Project > project name Properties > Application tab. Delete the Assembly Name and substitute your own. Make sure it has no spaces in it. 18. Click on the Assembly Information button in the same tab. Update title, Description and Copyright info as required. OK. OLD 19. Open the Build Events tab and check the path to Paint.NET is correct. This copies the built effect directly to the Paint.NET/effects directory. FOR FUTURE REFERENCE >> In between builds you need to delete the old *.dll file and close Paint.NET. New 19. Select Debug tab - change to "Start external program" - Enter command line to start Paint.NET IE: C:\Program Files\Paint.Net\Paintdotnet.exe Does working directory need to be filled? If so I just use C:\Program Files\Paint.Net\ Click Enable native code debugging 20. Save project. Build just builds the project. Debug is used to create the *.dll This is the error I get when trying to build. Related to error in Step 15. Severity Code Description Project File Line Suppression State Error CS1705 Assembly 'PaintDotNet.Effects' with identity 'PaintDotNet.Effects, Version=4.300.7918.1291, Culture=neutral, PublicKeyToken=null' uses 'System.Runtime, Version=184.108.40.206, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.Runtime' with identity 'System.Runtime, Version=220.127.116.11, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' StarryNight C:\Users\Andrew\Desktop\Training\StarryNight\CSC 1 Active I will stop here until I can resolve that error. I have debugged a few plugins successfully and can finish off the walkthrough when I get that error resolved. My how things have changed for the next three steps. 20. Build project (F6). The post-build copy should drop the *.dll into the correct PDN folder. Open PDN and see if the plugin appears. (If the build fails with an error in "resx" file, change the icon reference in the resx file to 18.104.22.168). 21. If the dll builds successfully with no errors and is in Pdn/effects folder ok, but the effect does not show up in the PDN menu. Try building it without an Icon i.e. 'return null' to see if that is where the problem lies. 22. Return to the EffectPlugin.cs file (it should be a tab on the main window). Scroll to the bottom of the file and you'll find the Render method. This is where the heart of your plugin should go. See where it says // Render code Here - bung your code in there! I envision adding code snippets to this thread to provide addition help in building a plugin. They are spread all over the place. Your help would be appreciated Edited September 7, 2021 by AndrewDavid 1 Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.