AXIsProcessTrustedWithOptions doesn't work

I'm developing in Visual Studio for mac using C sharp.

I'm using AXIsProcessTrustedWithOptions() to get accessibility permissions, but sometimes the behavior is strange.
Code Block
var key = new NSObject[] { FromObject("AXTrustedCheckOptionPrompt") };
var obj = new NSObject[] { FromObject((NSNumber)1) };
var options = NSDictionary.FromObjectsAndKeys(obj, key);
AXIsProcessTrustedWithOptions(options.Handle);

Specifically, it looks like this:
  • "Accessibility Access" dialog will appear.

  • Click "Open System Preferences".

  • There isn't my app in the list and can't turn on

Some users of macOS Mojave are experiencing this issue.
Does anyone have any solutions?
This is the result of executing the following commands on the terminal where the problem occurs.
Code Block
$ tccutil reset Accessibility [com.myapp]
tccutil: Failed to reset Accessibility approval status for [com.myapp]

After some research, I found a description that says /Library/Application Support/com.apple.TCC/TCC.db is corrupted when I get this kind of result.
AXIsProcessTrustedWithOptions doesn't work
 
 
Q