Question

Error: Showing a modal dialog box, API C# .NET

  • 27 January 2021
  • 5 replies
  • 480 views

Userlevel 2
Badge +5

Hi,

 

I have a web API in C# using Fnd library to use IFS. Sometime I get an error that in thrown when executing a query. For example :

FndPLSQLSelectCommand cmd = new FndPLSQLSelectCommand(Connection, query);           

FndDataTable table = cmd.ExecuteReader(); // <-- Error thrown here

The error thrown is :

Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at Ifs.Fnd.Windows.Forms.FndMessageBox.Show(String message, String title, MessageBoxButtons buttons, FndMessageBoxIconEx icon, MessageBoxDefaultButton defaultButton, FndMessageBoxDetails messageDetails, String checkBoxMessage, Boolean& checkedValue, Int32 timeout)
at Ifs.Fnd.FndException.Show(Form ownerForm)
at Ifs.Fnd.AccessProvider.FndConnection.InvokeInternal(Object requestBody, Object responseBody, String intface, String operation, FndRequestContext requestContext, FndManualDecisionCollection decisions, Boolean forcedSync)
at Ifs.Fnd.AccessProvider.FndConnection.InvokeInternal(String intface, String operation, Object requestBody, Object responseBody, FndRequestContext requestContext, Boolean forcedSync)
at Ifs.Fnd.AccessProvider.PLSQL.FndPLSQLCommandCollection.Invoke()
at Ifs.Fnd.AccessProvider.PLSQL.FndPLSQLSelectCommand.ExecuteReader()
at SII.IFSWebApp.Repositories.v2.IFS.ExpenseLineRepository.All(String expenseId, String search, Nullable`1 offset, Nullable`1 limit) in D:\Projet\ifs-webservices-dotnet-hotfix-add-log-global\SII.IFSWebAPI\SII.IFSWebApp\Repositories\v2\IFS\ExpenseLineRepository.cs:line 66
at SII.IFSWebApp.Services.WS.v2.ExpenseLineService.GetAll(String expenseId, String search, Nullable`1 offset, Nullable`1 limit) in D:\Projet\ifs-webservices-dotnet-hotfix-add-log-global\SII.IFSWebAPI\SII.IFSWebApp\Services\WS\v2\ExpenseLineService.cs:line 23
at SII.IFSWebApp.Controllers.v2.ExpenseLinesController.Index(String expenseId, String search, Nullable`1 offset, Nullable`1 limit) in D:\Projet\ifs-webservices-dotnet-hotfix-add-log-global\SII.IFSWebAPI\SII.IFSWebApp\Controllers\v2\ExpenseLinesController.cs:line 42
at SII.IFSWebApp.Controllers.v2.ExpenseLinesController.Index(String expenseId, Nullable`1 offset, Nullable`1 limit) in D:\Projet\ifs-webservices-dotnet-hotfix-add-log-global\SII.IFSWebAPI\SII.IFSWebApp\Controllers\v2\ExpenseLinesController.cs:line 33
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_2.<GetExecutor>b__2(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)

This error is “legit” because it try to open a window (System.Windows.Forms.Form.ShowDialog) but it doesn’t make sens it’s an API.

Do you have any idea how to fix it? Maybe it’s a configuration with Ifs.Fnd.AccessProvider

 

Thanks for your help,

Antoine


This topic has been closed for comments

5 replies

Userlevel 4
Badge +8

Turn exception handing off on the FndConnection. I suspect the form window is an exception pop-up.

 

If you turn IFS exception handling off you need to use your own try/catch.

Userlevel 7
Badge +19
conn = new FndConnection(sConnectionString, sUsername, sPassword);
conn.CatchExceptions = false; // This is to be able to catch errors and not show IFS dialog box.

 

Userlevel 2
Badge +5

Okay thanks for your answers.

I am disappointed because I have some unexplainable “Bad credentials” error on random URLs and I thought it could be the issue. Usually the property CatchExceptions is set to false.

If you have any idea about an “unexplainable” bad credential error let me know :D

 

Userlevel 4
Badge +8

Hi Antoine,

 

Please can you implement some logging (log4net works great) and write out your variables and the full exception stacktrace.

Another thing to check is the timeout on the FndConnection, is it possible your connection could experience some latency and cause the error?

Userlevel 2
Badge +5

Hello,

 

Yes I tried but I guess the problem is directly linked to IFS server. I will try to find some log.

Thanks for your help