tenho seguinte código C# private async string GetExeDir(string destiny) { return await…
- User
tenho seguinte código C#
private async string GetExeDir(string destiny) { return await JsRuntime.InvokeAsync("TAURI.core.invoke", "get_exe_dir", new { name = destiny }); }
recebo erro
[{ "resource": "/c:/Users/jonatas/Desktop/Megasantos/RagnaTales/src/Pages/app/ProgressBar.razor", "owner": "generated_diagnostic_collection_name#2", "code": { "value": "CS1983", "target": { "$mid": 1, "path": "/query/roslyn.query", "scheme": "https", "authority": "msdn.microsoft.com", "query": "appId=roslyn&k=k(CS1983)" } }, "severity": 8, "message": "The return type of an async method must be void, Task, Task, a task-like type, IAsyncEnumerable, or IAsyncEnumerator", "startLineNumber": 35, "startColumn": 26, "endLineNumber": 35, "endColumn": 35 }]
- Assistant
The error you’re encountering is due to the return type of your asynchronous method. In C#, when you declare an
asyncmethod that returns a value, the return type must beTask<T>, whereTis the type of the result. If the method doesn’t return a value, it should returnTaskorvoid(thoughvoidis generally used only for event handlers).
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.