I'm trying to implement plattform specific partial method in .NET MAUI to get the connection string for the database.
In the "main application":
namespace TestApp.DL;
public partial class BaseHandler
{
public partial string GetDBPath();
private string GetCnnPath()
{
var dbPath = GetDBPath();
var cnnPath = $"Data Source={dbPath}";
return cnnPath;
}
...
}
in the platform folders in the project:
where each contain the plattform specific implementation:
namespace TestApp.DL;
// All the code in this file is only included on Android.
public partial class BaseHandler
{
public string GetDBPath()
{
var dbName = "com.mycompany.mydatabase.db";
return Android.App.Application.Context.GetDatabasePath(dbName).AbsolutePath;
}
}
...but I keep getting "Error CS8795: Partial method 'BaseHandler.GetDBPath()' must have an implementation part because it has accessibility modifiers. (CS8795)". It seems like the platform specific files are not seen by the compiler? Note, they are in a separate assembly project from the main application but that should be ok I guess, given that the fwk created the folders for me?