Page 1 of 1

Getting error on asynchronous anonymous method on editor

PostPosted: Thu Jul 21, 2022 6:00 am
by sameermoin
I am calling a third-party API inside a Business Logic Setup method. This Setup method is lacking the async keyword so I am running the asynchronous code inside
Code: Select all
Task.Run( async () => await TestMethod())
but here I am getting an error on it.

Which dotnet version is recommended to write the custom Plugin?

How can I resolve this error?

Screenshot 2022-07-20 235002.png
Error Screenshot

Re: Getting error on asynchronous anonymous method on editor  Topic is solved

PostPosted: Thu Jul 21, 2022 10:02 am
by SBarnes
What you may be seeing is a false error, Jiwa uses a third party syntax editor in the plugin editor this control only support up to a given version of c#, however this control doesn't actually do the compiling of the plugin, save you plugin and restart Jiwa if no error dialog about plugins it couldn't compile is shown then it compiled it.

Alternatively Jiwa supports embedded references so you can build a class library and embed you code in there to do this you do the following:

Create a class library that target X86 and uses the ,net 4.7 framework, you can use 4.8 but Jiwa installs 4.7
Add references to JiwaApplication and JiwaODBC if you are going to need to access Jiwa from the class library
Create a public class called worker for instance and put your code in some method and pass in the manager if you need to
Compile your library
Create a plugin and add the library as an embedded reference, save it and restart Jiwa
Now in the appropriate plugin instantiate your worker class and call your method.

What I quite often do is in the solution with the library is create a win forms application as a test and have the following code to create the Jiwa connection and then call the library


Code: Select all
JiwaFinancials.Jiwa.JiwaApplication.Manager  manager = new Manager();
manager.Logon("SERVERNAMEGOESHERE", "DATABASENAMEGOESHERE", JiwaFinancials.Jiwa.JiwaODBC.database.AuthenticationModes.JiwaAuthentication, "Admin", "password");

Re: Getting error on asynchronous anonymous method on editor

PostPosted: Fri Jul 22, 2022 4:28 pm
by sameermoin
This is making debugging very difficult. I am testing some code that is running fine in a simple visual studio console application but after embedded into the library and referencing that library in the Jiwa I am getting an error on it. So how can I do debugging in this situation?

Re: Getting error on asynchronous anonymous method on editor

PostPosted: Fri Jul 22, 2022 4:37 pm
by SBarnes
if you are on a machine with Visual studio installed simply put the following lines inside the class library at an appropriate spot and make sure you compile as debug and not release.


Code: Select all
System.Diagnostics,Debugger,Launch();
System.Diagnostics,Debugger,Break();


The just in time debugger will then gets launched, you can do the same thing in plugin code as well, I do this all the time.

In fact usually I create a class like the following and place the call to the static method on the static class i.e Debug.DoDebug() throughout my code and then I just have to comment out two lines to make sure the break code is not in the final library.

Code: Select all
 public static class Debug
    {

        public static void DoDebug()
        {
            System.Diagnostics.Debugger.Launch();
            System.Diagnostics.Debugger.Break();
        }
    }

Re: Getting error on asynchronous anonymous method on editor

PostPosted: Fri Jul 22, 2022 5:25 pm
by Mike.Sheen
sameermoin wrote:This is making debugging very difficult. I am testing some code that is running fine in a simple visual studio console application but after embedded into the library and referencing that library in the Jiwa I am getting an error on it. So how can I do debugging in this situation?


If you're talking about the noise from the Plugin Editor showing errors which are not really errors that are preventing compilation, then you'll note the first column of the Error Messages listview is Source - when that is "Editor" then it's not the compiler producing the error - so you can just ignore those ones.

If you have any genuine errors, we don't let you save the plugin enabled with errors which prevent compilation.

In the next release the editor won't report problems with async anonymous methods - we've fixed that by upgrading the editor control used.

Re: Getting error on asynchronous anonymous method on editor

PostPosted: Fri Jul 22, 2022 6:13 pm
by SBarnes
Given the compiler and editor version of c# are likely never to be in sync would a nice enhancement be some sort of filtering in the user interface such as checkboxes or a dropdown?

It would get rid of the "noise"