Create dll for Wonderware System Platform

Tanquen

Member
Join Date
Jul 2014
Location
CA
Posts
163
I was given some example code but I can not get the function to show up in the System Platform script.

The dll import is successful but I'm unsure how to reference it in script or if I created it with the wrong Visual Studio template type, Windows Forms Class Library - c#.

This is the dll code:

using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace WinFormsLibrary1
{
public class ResizableForm
{
[DllImport("user32.dll")]
public static extern IntPtr GetForegroundWindow();

public Form GetCurrentWindow()
{
IntPtr activeWindowHandle = GetForegroundWindow();
Form f = Control.FromHandle(activeWindowHandle) as Form;
return f;
}
}
}


When I try to use it in script I get the error, Unknown Type.

Also tried "WinFormsLibrary1.ResizableForm"

Dim myLib As ResizableForm;
Dim myGfc As System.Windows.Forms.Form;

myLib = new ResizableForm();
myGfc = myLib.GetCurrentWindow();

myGfc.Width = #;
myGfc.Height = #;
 
I found this thread and they are doing something similar.
http://www.plctalk.net/qanda/showthread.php?t=114301

At first the code had errors about the Windows Forms in Visual Studio but I found you can add a reference to the System.Windows.Forms in the Class Library (.NET Framework) template. So, I now get a dll that I can import into System Platform, it is listed under the Script Function Browser and the script has no errors but in runtime nothing happens when the button with the script is used and this is in the SMC log: Script execution exception.Message: Non-static method requires a target..
System.Reflection.TargetException: Non-static method requires a target.
 

Similar Topics

Hello, I've been trying to learn this a while now and still have not found out how this works. I have an Omron CJ2M PLC and an ABB ACS 355 VFD...
Replies
1
Views
243
Hello, I have to deal with iFix again and am looking at the most efficient way to create alarms to display in iFix, i.e. not creating an...
Replies
0
Views
154
Good morning to all, I have the following issue, I installed everything of intouch including the patch, it is the 2023 version. The...
Replies
0
Views
330
So, I finally got versioin 27 installed on my Windows 10 VM. However, now I can't upload a project from my lab controller. I have the above error...
Replies
0
Views
1,129
Hi all, I have few GB of logged data created by RS View 32 Works, it is all in .DBF format. At the moment, my company wants to shift all data to...
Replies
14
Views
1,450
Back
Top Bottom