Jump to content

VB.Net Effect Plugin Template (Indirect UI)

Recommended Posts

well I beleive there are three types of people in this world.

stupid people that never learn from mistakes theirs or others

intelligent people that learn from their mistakes


geniuses that learn from the mistakes of others and don't make the same.

I'm thinking I'm a genius. :lol::lol::lol: :wink:

if I ever figure out this book that is. :lol::lol:

Link to post
Share on other sites
  • 3 weeks later...

Hi everyone, I'm trying to get this template working under VS2008express. Rick Brewster's instructions don't work because the express version Project/Properties/Debug tab lacks the option to start an external program. There is a reply on that thread from someone who claims to have got it working under VS express but it leaves me none the wiser.

I decided to rummage around for a way of getting the Template code running myself, guided largely by blithe ignorance. What I came up with was this :

Unzipped the template in the VB2008\Project Templates folder.

Started the vbproj with VS2008. VS2008 converts it successfully but there are 40+ errors.

Added the folder "C:\Program Files\PaintDotNet\" on the Project/References tab.

This reduces the tally to 1 warning and 1 error. These are as follows:

Warning	1	Load of property 'RootNamespace' failed.  The string for the root namespace must be a valid identifier.
Error	2	'$safeprojectname$' is not a valid name and cannot be used as the root namespace name.

There is no indication of which file is responsible for the error.

Does anyone have a suggestion how I can proceed from here? Or am I barking up the wrong tree altogether?

Regards, Boopz

Link to post
Share on other sites
Unzipped the template in the VB2008\Project Templates folder.

Wait, you UNZIPPED it?

I thought that was undesireable? jchunn specifically warned against this in the original post:

Here is how to install and use the template:

Step 1: DO NOT UNZIP THE FILE. Download the zip file and save it into your templates directory (something like "C:\Documents and Settings\Jesse Chunn\My Documents\Visual Studio 2005\Templates\ProjectTemplates"). DO NOT UNZIP THE FILE... Visual Studio knows how to handle the zipped file. DO NOT UNZIP THE FILE... EVER.

I have got the template working under VB2008, but I don't recall getting the problem you have mentioned. Try not unzipping the template and see where this gets you.

Link to post
Share on other sites
Unzipped the template in the VB2008\Project Templates folder.

Wait, you UNZIPPED it?

Yes, I thought I could get away with it in the privacy of my own home. And now the universe is going to collapse. Sorry about that. :|

Of course, I had already tried doing it with the ZIP file as specified. I was able look at the code in VS2008 but when I tried to run it I got this message:

"A project with an Output Type of Class Library cannot be started directly. In order to debug this project, add an executable project to this solution which references the library project. Set the executable project as the startup project."

So I tried making a simple Windows Forms project to use as a startup project. Then I tried to add a reference, but as far as I could see VS Express does not offer a way of adding a reference to a ZIP file. Hence my dastardly deed.

I'd appreciation any suggestion about what else to try.

All the best, Boopz

Link to post
Share on other sites

That's right, a *.dll is not going to run by itself. In this case we need PDN to load and run it. So we can build it but not run it from the VB IDE.

After you build it, copy the *.dll to /paint.net/effects (you'll find the *.dll located in the project's Bin/Debug folder).

Now when you start PDN, it will find the *.dll and load it into the Effects menu.

Note that you will need to restart PDN after each build to make sure the most recent build loads.

Link to post
Share on other sites

Thanks, EER, it's working fine now. Now I can get down to figuring out how the template works. A few things are starting to fall into place.

I have one final observation that may be useful to other Express newbies arriving here for information. I thought I'd be clever and set the template project's Build Output Path to the PdN Effects directory (in the project properties Compile tab). Forget it! It causes all kinds of problems and I wasted more than an hour before I discovered the cause.

It's this: VS express copies all the referenced PaintDotNet dlls (PaintDotNet.Core.dll etc.) into the target directory along with the template dll. It seems that when you run PdN it tries to interpret every dll in the Effects folder as a plugin, freaks out at finding itself digesting its own entrails, and refuses to load any Effect DLLs whatsover. (Thought: is this a bug?)

Once you know it, you can fix it just by deleting the 7 PaintDotNet dlls from the Effects folder after every build. But you might as well just use the default Build Output Path and copy the template dll from the project Obj\Release folder to the Effects folder after each build, as EER recommended.

all the best, Boopz

Link to post
Share on other sites

I'm not sure that VB 2008 Express allows post-build events. I know C# Express does, but in VB there is no corresponding "Build Events" tab under "Project Properties".

So unless I'm being thick about this, I just copy the *.dll manually after each build. Does anyone have a workaround for this in VB Express? It would be very useful to know...,

Link to post
Share on other sites

You can use a program to Close Paint.Net if running, copy the dll to the Effects menu and then restart Paint.Net. I've made a little example below in vb.net on a default Windows Form. No doubt it could be improved in various ways, but it seems to work so far. Here's how to use it:

1. compile the program

2. add the compiled program .exe to Visual Studio under Tools/External Tools...

3. link a key combination to the new External Tool (Tools/Customize/Keyboard...)

Now every time you rebuild your Paint.Net plugin, you just press one key (or combination) to go straight into PdN with your new plugin version loaded for use.

All the best, Boopz

Public Class Form1

   Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        'Close Paint.Net if running. I'm sure there must be a more elegant way but it works:
        Dim processes() = System.Diagnostics.Process.GetProcessesByName("PaintDotNet")
        If processes.Count > 0 Then
            'Wait a moment to allow the files to be released:
        End If

        'Copy the dll file overwriting any previous version:
         My.Computer.FileSystem.CopyFile(BuildFile, DestinationFile, True)
        'Start or restart Paint.Net:
        Dim PdNprocess As New System.Diagnostics.Process
        PdNprocess = Process.Start("c:\program files\Paint.Net\PaintDotNet.exe")

    End Sub
End Class

Link to post
Share on other sites

Now that is a really nice idea. Thank you :!:

  • Upvote 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...