Forum Xamarin.Forms

Can't see the MainPage in Designer

gtasyurekgtasyurek Member ✭✭
edited December 2019 in Xamarin.Forms

I created a Master-Detail template. And implemented some of my codes.

I've a IFileService interface which is in shared project. And its concrate class is in Android project. When i clicked to MainPage.xml in Solution Explorer im getting some errors like below.

Android.OS.Environment.GetExternalStoragePublicDirectory(System.String type)
MyApplication.Droid.Services.FileService..ctor in C:...\Services\FileService.cs 17
System.Reflection.RuntimeConstructorInfo.InternalInvoke

This is the FileService

...
using Environment = Android.OS.Environment;
using JFile = Java.IO.File;

[assembly: Dependency(typeof(FileService))]
namespace MyApplication.Droid.Services
{
    public class FileService : IFileService
    {
        private readonly JFile _androidPublicDownloadPath = Environment.GetExternalStoragePublicDirectory(Environment.DirectoryDownloads);

        private readonly string _workspaceDirectoryPath;
        private ReadWriteFileOutput output;
        public FileService()
        {
            _workspaceDirectoryPath = _androidPublicDownloadPath + "/" + "Workspace";
            output = new ReadWriteFileOutput();
        }
...
}

The line number where the _androidPublicDownloadPath variable is defined is 17.

MainPage.xaml.cs

    [DesignTimeVisible(false)]
    public partial class MainPage : MasterDetailPage
    {
        Dictionary<int, NavigationPage> MenuPages = 
            new Dictionary<int, NavigationPage>();

        private readonly IFileService _fileService = 
            DependencyService.Get<IFileService>();
Tagged:

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    This error shows something went wrong at the 17 line in your FileService.cs file. Try to check whether you made some errors there.
    However, I don't think this will stop you writing code in your MainPage file. What do you mean about you can't see it in designer?

  • gtasyurekgtasyurek Member ✭✭

    @LandLu said:
    This error shows something went wrong at the 17 line in your FileService.cs file. Try to check whether you made some errors there.
    However, I don't think this will stop you writing code in your MainPage file. What do you mean about you can't see it in designer?

    I Created new Master-Detail project. Implemented some of my code above. The application running without error. When i double click to MainPage.xaml. There is no visualization of xaml codes at MainPage.xaml. There is just error popup and white screen.

  • LandLuLandLu Member, Xamarin Team Xamurai

    Could you try to post your samples here?
    And what's the version of the Forms and VS now?

Sign In or Register to comment.