Neue Testversion 20.40b12

Hier diskutieren die Betatester von PhotoLine untereinander und mit den Entwicklern
User avatar
photoken
Mitglied
Posts: 2162
Joined: Sat 28 Sep 2013 01:25

Re: Prob: DLL and EXE do not run from Script sub-menu

Post by photoken »

As a test, I used VS2017 to create a DLL that re-uses my successful HelloWorld code. This DLL should simply create a text layer containing the text "Hello World from the DLL!".

I opened a 600px by 900px JPG image named "Jill.jpg".
Again, when running the DLL from the "Scripts" menu, nothing happens.

Attached is the class1.cs file and the compiled DLL.

Added:
I found that if I created a compiled executable that calls the Main() method of the DLL, it works if I run the ConsoleApp1.exe:

Code: Select all

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1 {
	class Program {
		static void Main(string[] args) {
			DLLtest02.Class1.Main();
		}
	}
}
So, it looks like some kind of entry point problem in PL....
You do not have the required permissions to view the files attached to this post.
Ken
Yes, I think it can be eeeeeasily done....
Just take everything out on Highway 61.
User avatar
Gerhard Huber
Entwickler
Entwickler
Posts: 4176
Joined: Mon 18 Nov 2002 15:30
Location: Bad Gögging

Re: Prob: DLL and EXE do not run from Script sub-menu

Post by Gerhard Huber »

photoken wrote: Fri 21 Jul 2017 08:16 Here's the class1.cs file and the compiled DLL:
I am sorry, but it is not so easy to create a C# dll that can be used in other programs.
The problem is, that there is no entry point created, normally.
I append my sample project.
What you have to do is:
- You have to add "UnmanagedExports" in the NuGet-Package Manager of Visual Studio
- You have to create an Entry function like this in your project:

Code: Select all

		[DllExport("Main", CallingConvention = CallingConvention.Cdecl)]
		public static void Main()
		{
			Export();	// The function to call
		}
You do not have the required permissions to view the files attached to this post.
User avatar
Gerhard Huber
Entwickler
Entwickler
Posts: 4176
Joined: Mon 18 Nov 2002 15:30
Location: Bad Gögging

Re: Prob: DLL and EXE do not run from Script sub-menu

Post by Gerhard Huber »

photoken wrote: Fri 21 Jul 2017 08:16 I found that if I created a compiled executable that calls the Main() method of the DLL, it works if I run the ConsoleApp1.exe:
this would work, but exe files are not a sub process of PhotoLine and therefore have a slow interface handling.
User avatar
photoken
Mitglied
Posts: 2162
Joined: Sat 28 Sep 2013 01:25

Re: Prob: DLL and EXE do not run from Script sub-menu

Post by photoken »

Gerhard Huber wrote: Fri 21 Jul 2017 09:20 I am sorry, but it is not so easy to create a C# dll that can be used in other programs.
The problem is, that there is no entry point created, normally.
I append my sample project.
What you have to do is:
- You have to add "UnmanagedExports" in the NuGet-Package Manager of Visual Studio
- You have to create an Entry function like this in your project:

Code: Select all

		[DllExport("Main", CallingConvention = CallingConvention.Cdecl)]
		public static void Main()
		{
			Export();	// The function to call
		}
OK, thanks!

I'll have a look at all this tomorrow (meaning later today... :wink: ).
Ken
Yes, I think it can be eeeeeasily done....
Just take everything out on Highway 61.
User avatar
photoken
Mitglied
Posts: 2162
Joined: Sat 28 Sep 2013 01:25

Re: Prob: DLL and EXE do not run from Script sub-menu

Post by photoken »

Gerhard Huber wrote: Fri 21 Jul 2017 09:22
photoken wrote: Fri 21 Jul 2017 08:16 I found that if I created a compiled executable that calls the Main() method of the DLL, it works if I run the ConsoleApp1.exe:
this would work, but exe files are not a sub process of PhotoLine and therefore have a slow interface handling.
Understood. That's why I'm trying to get the DLL thingy working....
Ken
Yes, I think it can be eeeeeasily done....
Just take everything out on Highway 61.
Martin Huber
Entwickler
Entwickler
Posts: 4220
Joined: Tue 19 Nov 2002 15:49

Neue Scripting-Dokumentation/new scripting documntation

Post by Martin Huber »

Ich habe die Scripting-Dokumentation in Gerhards Startbeitrag durch die aktuellste Version ersetzt. Es sollten nun alle Interfaces und alle verwendeten Strukturen enthalten sein.

I have replaced the scripting documentation in Gerhard's initial posting by the latest version. It should now include all interfaces and all used structures.

Martin
User avatar
Herbert123
Mitglied
Posts: 2277
Joined: Sat 12 May 2012 21:38

Re: Neue Testversion 20.40b12

Post by Herbert123 »

Back from holidays, and before that really busy with work. I can now finally have a look at the new scripting capabilities!

@Photoken: I see you've been playing around a lot! :D Would you mind explaining the coding environment setup you have to make this work?
/*---------------------------------------------*/
System: Win10 64bit - i7 920@3.6Ghz, p6t Deluxe v1, 48gb (6x8gb RipjawsX), Nvidia GTX1080 8GB, Revodrive X2 240gb, e-mu 1820, 2XSamsung SA850 (2560*1440) and 1XHP2408H 1920*1200 portrait
User avatar
photoken
Mitglied
Posts: 2162
Joined: Sat 28 Sep 2013 01:25

Re: Neue Testversion 20.40b12

Post by photoken »

Herbert123 wrote: Fri 21 Jul 2017 22:02 @Photoken: I see you've been playing around a lot! :D Would you mind explaining the coding environment setup you have to make this work?
Welcome back, my friend!

The development environment couldn't be more simple -- the free Visual Studio 2017 Community Edition:
https://www.visualstudio.com/

A word of advice: The thing that you download from that page is the small VS2017 installer. When you run the installer, it will connect to MS and download and install VS2017 and all the required supporting files. That download and installation procedure will take a loooooong time. Hours. I literally started the download & installation, put the Thinkpad aside, cooked dinner, ate dinner, washed the dishes, and then ate dessert. When I came back to the Thinkpad, the installation procedure was at about 90% complete. :shock:

VS is a dream to use. If you've never used it, you can go through the various "Getting Started" tutorials. VS can be highly customized, and has some excellent AddIns available to get from within the IDE. You can code in your favorite language and the AddIns and Scripts you create should work. I suspect that AddIns built with the .Net Windows Forms GUI won't work on non-Windows OSes, but non-interactive AddIns and Scripts should be OK anywhere.

To set up VS2017 to create PL stuff, after you create a new VS Solution, in the Solution Explorer panel right-click on the "References" item and choose "Add Reference". In the next dialog window, expand the "COM" item on the left and select "Type Libraries". Scroll down the list and select "PhotoLIne", place a checkmark in the box next to the item and hit the "OK" button. Now you'll be good to go and have full IntelliSense, code completion and Type Library exploration for the PL functions. Note: when a newer version of PL is released, you'll have to open your solutions that used the older version of PL, delete the old "PhotoLine" reference, and repeat the above procedure to load the newer PL Type Library.

If you get stuck, just give a holler and I'll see what I can advise.

As of now, I've decided that (because I will not code in any language other than C#) instead of writing a "script", I'll write the code and compile it into a DLL. Additionally, I'll create AddIns (to support getting user input from a GUI, and also support localization for various languages) as either compiled executables or compiled DLLs (which I will be trying to learn this weekend).
Ken
Yes, I think it can be eeeeeasily done....
Just take everything out on Highway 61.
User avatar
Herbert123
Mitglied
Posts: 2277
Joined: Sat 12 May 2012 21:38

Re: Neue Testversion 20.40b12

Post by Herbert123 »

Thanks, Ken. I'll be checking it out this upcoming week. I have worked with VS before, so it should not be an issue.

Cheers!
/*---------------------------------------------*/
System: Win10 64bit - i7 920@3.6Ghz, p6t Deluxe v1, 48gb (6x8gb RipjawsX), Nvidia GTX1080 8GB, Revodrive X2 240gb, e-mu 1820, 2XSamsung SA850 (2560*1440) and 1XHP2408H 1920*1200 portrait
User avatar
photoken
Mitglied
Posts: 2162
Joined: Sat 28 Sep 2013 01:25

Re: Prob: DLL and EXE do not run from Script sub-menu

Post by photoken »

I still cannot create a DLL that works. :(

I have downloaded your PhotoLineScriptDLL.zip, opened the solution in VS2017 and compiled it (targeting the x64 platform). When I choose it from the PL Scripts submenu, nothing happens.

So, I created a new VS2017 solution as a test. To eliminate as many variables as possible, this test DLL should display a simple form and, when the "OK" button is clicked, do only one simple thing: display a MessageBox.

Here's the entire code for the Form1.cs:

Code: Select all

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Resources;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using RGiesecke.DllExport;

namespace DLLtest01 {
	public partial class Form1 : Form {
		[DllExport("Main", CallingConvention = CallingConvention.Cdecl)]
		public static void Main() {
			ShowMessage();
		}

		public Form1() {
			InitializeComponent();
		}

		static void ShowMessage() {
			MessageBox.Show("Hello World!", "Test", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
		}

		private void OKbutton_Click(object sender, EventArgs e) {
			ShowMessage();
		}
	}
}
Same result -- nothing happens.

I don't know what else to try....
Ken
Yes, I think it can be eeeeeasily done....
Just take everything out on Highway 61.
User avatar
Gerhard Huber
Entwickler
Entwickler
Posts: 4176
Joined: Mon 18 Nov 2002 15:30
Location: Bad Gögging

Re: Neue Testversion 20.40b12

Post by Gerhard Huber »

Can you send me your dll?
User avatar
photoken
Mitglied
Posts: 2162
Joined: Sat 28 Sep 2013 01:25

Re: Prob: DLL and EXE do not run from Script sub-menu

Post by photoken »

Here's the test DLL:
You do not have the required permissions to view the files attached to this post.
Ken
Yes, I think it can be eeeeeasily done....
Just take everything out on Highway 61.
User avatar
Gerhard Huber
Entwickler
Entwickler
Posts: 4176
Joined: Mon 18 Nov 2002 15:30
Location: Bad Gögging

Re: Neue Testversion 20.40b12

Post by Gerhard Huber »

the dll has no entry point.
Can you send me the dll, that you created from my project?
User avatar
photoken
Mitglied
Posts: 2162
Joined: Sat 28 Sep 2013 01:25

Re: Neue Testversion 20.40b12

Post by photoken »

Gerhard Huber wrote: Tue 25 Jul 2017 10:44 the dll has no entry point.
Can you send me the dll, that you created from my project?
Here it is:
You do not have the required permissions to view the files attached to this post.
Ken
Yes, I think it can be eeeeeasily done....
Just take everything out on Highway 61.
User avatar
Gerhard Huber
Entwickler
Entwickler
Posts: 4176
Joined: Mon 18 Nov 2002 15:30
Location: Bad Gögging

Re: Neue Testversion 20.40b12

Post by Gerhard Huber »

this one has an entry point and works here, as expected.