Getting error on asynchronous anonymous method on editor  Topic is solved

Discussions relating to the REST API of Jiwa 7.

Getting error on asynchronous anonymous method on editor

Postby sameermoin » Thu Jul 21, 2022 6:00 am

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
sameermoin
Regular Contributor
Regular Contributor
 
Posts: 75
Joined: Wed Jun 15, 2022 4:02 am
Topics Solved: 1

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

Postby SBarnes » Thu Jul 21, 2022 10:02 am

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");
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Getting error on asynchronous anonymous method on editor

Postby sameermoin » Fri Jul 22, 2022 4:28 pm

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?
sameermoin
Regular Contributor
Regular Contributor
 
Posts: 75
Joined: Wed Jun 15, 2022 4:02 am
Topics Solved: 1

Re: Getting error on asynchronous anonymous method on editor

Postby SBarnes » Fri Jul 22, 2022 4:37 pm

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();
        }
    }
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Getting error on asynchronous anonymous method on editor

Postby Mike.Sheen » Fri Jul 22, 2022 5:25 pm

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.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Getting error on asynchronous anonymous method on editor

Postby SBarnes » Fri Jul 22, 2022 6:13 pm

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"
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175


Return to REST API

Who is online

Users browsing this forum: No registered users and 3 guests