0

I am working with Visual Studio 2019 Community Edition Version 16.7.2.

I have referenced the SapBusinessOneSDK.dll inside a .Net Core Console Application to access SAP B1 via DI API and I am not able to inspect any Sap B1 COM Object while debugging. The error appearing is:

“The function evaluation requires all threads to run.”

enter image description here

This are the project properties of the mentioned Console App in the Debug Section:

enter image description here

And this are the Visual Studio Options relevant to Debugging:

enter image description here

How should I proceed?

Thanks

jpchauny
  • 386
  • 2
  • 9
  • How did you reference `SapBusinessOneSDK.dll`? Is it a install sdk? How did you download and use it? – Mr Qian Sep 03 '20 at 10:12
  • 3
    Console mode apps are in general a hostile place for COM components. Add the [STAThread] attribute to Main() to try to get ahead. – Hans Passant Sep 03 '20 at 23:20
  • @HansPassant you are right, adding the [STAThread] attribute to Main() resolved the problem. Thank you very much! – jpchauny Sep 04 '20 at 11:27
  • @PerryQian-MSFT SapBusinessOneSDK.dll will be installed when installing Sap B1 SDK – jpchauny Sep 04 '20 at 11:28
  • @HansPassant Do you want to answer the question formally or should I answer it by my own? – jpchauny Sep 04 '20 at 14:44
  • First, thanks to `Hans` for sharing the useful workaround and I have added it as an answer to help improve this issue better:) Finally, thanks for everyone's help. – Mr Qian Sep 07 '20 at 02:04
  • @jpchauny, you can accept this answer so that it will help other community members search and handle similar issues:) – Mr Qian Sep 14 '20 at 05:59

1 Answers1

2

Thanks for Hans sharing the useful workaround and add it as an answer to manage this issue better.

Since you have reference a com component dll on a console app and Console mode apps are usually a hostile locations place for COM components, you should add the [STAThread] to get into it.

[STAThread]
static void Main(string[] args)
{

// any code


}
Mr Qian
  • 21,064
  • 1
  • 31
  • 41