Rick Brewster Posted May 26, 2007 Posted May 26, 2007 If you've written a plugin DLL with Visual Studio, you probably know that you can't really debug a DLL by itself. This becomes a sticky point for developing a plugin: how do you debug it!? Visual Studio has excellent facilities for debugging when you are launching an EXE, but for your plugin DLL it's a little more confusing. Note: These instructions do not pertain to CodeLab plugins. The trick is to set up your project settings so that you are actually launching Paint.NET! In this post, I will show you how. I have used this myself while developing some of the plugins I've posted in the past (e.g., HD Photo). I'll use the HD Photo plugin an example. You can get the source code for it by downloading the source code for Paint.NET v3.07: http://www.getpaint.net/download.html . It is in the "extras" folder. Edit: The source code has long since been taken down. Please do not ask for it. Thanks. 1. Open up your project file in Visual Studio. (This much should be obvious 8)) 2. Right click on your project in the Solution Explorer and then click on Properties. 3. Click on the "Debug" tab. 4. Click the "Start external program" radio button, and fill in the path to the Paint.NET executable. 5. Make sure to fill in the Working Directory as well. After you complete steps 4 and 5, you should have this: 6. You will want to create a custom Post Build Event that will copy your plugin DLL to the appropriate location. Otherwise Paint.NET won't be able to find your plugin, or it will use an older version. Like so: (Naturally, if you are setting this up for an Effect plugin, make sure to copy it to the Effects directory, not the FileTypes directory!) 7. Set a breakpoint in your code. This isn't a requirement -- I am listing this for illlustration purposes. As you get better with the debugger, or if you're already a ninja, you will do whatever is necessary. 8. And then run Paint.NET with the Debug -> Start Debugging menu item. Now when there is an exception in your plugin, you will be thrown in to the debugger instead of getting a crash dialog. You can then debug it using the standard Visual Studio debugging commands. 3 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
MadJik Posted May 27, 2007 Posted May 27, 2007 Thank you so much, Rick, I only have the Express version, I will try this (should work as well). EDIT: It doesn't work with Express version! EDIT2: Could you add the texts so we could copy/paste (We can't do it from the screenshots). Quote My DeviantArt | My Pictorium | My Plugins | Donate via Paypal
moc426 Posted May 27, 2007 Posted May 27, 2007 What I did in express edition was to create a new effect in pdn source under PaintDotNet.Effects. Create the dialog for it ... etc. Then when you start the debugger, the dll is built with the core application and can be debugged. When I am done debugging, I copy the render function to my dll solution. And I can make any minor adjustments and compile the dll. Quote
SeriousSam Posted April 8, 2009 Posted April 8, 2009 This is how I was able to get debugging working with VS2008 C# Express Edition What is missing from the express edition is the start external program option. However, it can still be set manually in the "*.csproj.user" file found in the project directory. First I opened up the "*.csproj.user" file in notepad. It looked like: I added the following commands: Program C:\Program Files\Paint.NET\PaintDotNet.exe C:\Program Files\Paint.NET\Effects Make sure these paths are correct for your own system This completes steps 1-5 from Rick's guide. Next open the solution and set the post build event to copy the dll to the Paint.Net\Effects directory (Rick's Step 6) With Vista I found it was necessary to run visual studio as an admin or the file copy in the post build would fail. Setting the run as admin flag in the VCSExpress.exe compatibility properties will cleared this up. Happy debugging Quote
MadJik Posted April 8, 2009 Posted April 8, 2009 @SeriousSam Thanks for this info. I'm able to build/debug the DLL and run the Paint.net program. But, I can't see any effect in the effects menu... So I can't run mine for debugging... I've checked the paths and everything... Quote My DeviantArt | My Pictorium | My Plugins | Donate via Paypal
SeriousSam Posted April 9, 2009 Posted April 9, 2009 MadJik, if you open of the file menu do you see a menu item exclamation with that says "View Plugin Load Errors ..." errors? If this is there it will show a stack trace and you can figure out what is throwing an exception and why the plugin is not getting loaded. Also double check the plugin is copied to the effects directory when your project is built. Take a look at the date created of the file in the effects directory to make sure it is current. If you move the dll to the effects directory does it show up normally? I had the wrong namespace when loading the embedded image for the icon in my project and this caused it to not load. Quote
MadJik Posted April 9, 2009 Posted April 9, 2009 When I change the output build folder, it corrupts my paint.net installation. No more plugin is available in the menus. But the DLL are still in the effects folder! I had to uninstall pdn, and delete the folder and the entries in the registry (regedit) to be able to reinstall a correct version. ____________________ I'm used to build in the default folder "bin\debug" or "bin\release". So I build a debug version in the "bin\debug" (the pdn run doesn't work) and manually copy the DLL to the effects folder, then I press F5 again, and then it's ok to debug! Yes! (tricky, but it works...) Quote My DeviantArt | My Pictorium | My Plugins | Donate via Paypal
SeriousSam Posted April 9, 2009 Posted April 9, 2009 MadJik, that is a tricky way to get debugging to work. I did not change the output directory or configuration for my project, it is still Bin\debug. This is different from changing the working directory. Are you able to see the "View Plugin Load Errors ..." menu item when no plugins get loaded? This helped me a lot. Either way, glad to see you have a work-around. Quote
MadJik Posted April 9, 2009 Posted April 9, 2009 Ok, now I get it working properly... I've first changed the .csproj because I didn't find .csproj.user Then the .csproj.user has been created and I made the changes you described... All plugins are here, and no error log in the file menu... Thank you for your help. Quote My DeviantArt | My Pictorium | My Plugins | Donate via Paypal
Paul Posted August 28, 2009 Posted August 28, 2009 This is what I got when I went to Debug* Quote Is it really nessecary to put text here? Thought not
Simon Brown Posted August 28, 2009 Posted August 28, 2009 This is what I got when I went to Debug* I'm guessing you're using the express edition? In which case, try SeriousSam's suggestion. Quote
Paul Posted August 28, 2009 Posted August 28, 2009 Part yes. I am but this is Visual Basic I'm running. Is there help for visual basic? Quote Is it really nessecary to put text here? Thought not
Simon Brown Posted August 28, 2009 Posted August 28, 2009 If you write plugins without a debugger the PDN crash log/plugin crash dialog will at least tell you which exception has been thrown if it crashes. Quote
Paul Posted August 28, 2009 Posted August 28, 2009 Oh one more question? How do you make it a DLL? Quote Is it really nessecary to put text here? Thought not
Simon Brown Posted August 28, 2009 Posted August 28, 2009 Side note: For debugging, see http://tinyurl.com/6lnldc. If your project is already a "class library," then when you build the project a DLL will be created in Documents\Visual Studio 2008\Projects\{Your Project Name}\bin\{Release or Debug}. Quote
APShredder Posted November 26, 2009 Posted November 26, 2009 Can someone help me? I am using the Express Edition. So I tried to follow SeriousSam's suggestions, but when I open up the .csproj.user file in notepad the only line is see is: So is it possible for me to be able to debug with what I have? Thanks in advance. Quote BlendModes Plus | Dissolve | Extract Color
Simon Brown Posted November 26, 2009 Posted November 26, 2009 If you can't enable debugging and haven't already done this, copying the .PDB file over to the Effects folder as well will at least give you line numbers for crashes. Quote
pleabo Posted December 16, 2010 Posted December 16, 2010 (edited) RE: Template for Plugin Development using Visual C# 2010 Express - Unsuccessful try! Start with Madjic's Stars plugin source Run through Visual C# 2010 Express conversion wizard - no errors or warnings Change Assembly name and StaticName to V2 Change Build Events path to match my machine - C:\Program Files\Paint.Net\Effects Add PaintDotNet.Base reference Start Debugging (F5) runs nicely, copying the new DLL to the .Effects folder, and PDN starts up with no errors. However, the V2 effect is not showing up in the Render effects list or any place else. Setting break points in various places, the only hit is at StaticName->get. Would appreciate any help with this conversion to C# 2010 Express or another template to use. The goal is to produce a plugin with my design of the Dialog window. TIA, PatrickL Edited December 16, 2010 by pleabo Quote
Rick Brewster Posted December 16, 2010 Author Posted December 16, 2010 Go to the Debug menu, then click Exceptions... In that window, make sure that for the "Common Language Runtime Exceptions" item, that both the checkboxes for "thrown" and "user-unhandled" are checked. Then, re-run. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
Ego Eram Reputo Posted December 17, 2010 Posted December 17, 2010 I'm also using VS Express. If the *.dll is not showing up, you may have targeted .Net 4.0 when you need to target 3.5. Go to the Solution Explorer double click Properties > Application tab. Under the Target Framework heading, choose .Net 3.5 from the dropdown list. Save & rebuild. note you may be prompted to close & reopen the project. Do so. Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker
pleabo Posted December 17, 2010 Posted December 17, 2010 Go to the Solution Explorer double click Properties > Application tab. Under the Target Framework heading, choose .Net 3.5 from the dropdown list. Bingo! Thank you. Now I can have some fun. PatrickL Quote
Ego Eram Reputo Posted December 18, 2010 Posted December 18, 2010 It can take a while to find that one Glad it worked for you. Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.