IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C# Discussion :

Erreur de compilation Projet C# Xamarin [Débutant]


Sujet :

C#

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé Avatar de Tchicken
    Homme Profil pro
    Responsable d'exploitation informatique
    Inscrit en
    Août 2017
    Messages
    108
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Val d'Oise (Île de France)

    Informations professionnelles :
    Activité : Responsable d'exploitation informatique

    Informations forums :
    Inscription : Août 2017
    Messages : 108
    Par défaut Erreur de compilation Projet C# Xamarin
    Bonjour à tous,

    je travail sur mon premier projet C# avec Xamarin pour développer une petite application de consultation de données à travers un mobile et je bloque sur une erreur de compilation que je ne comprend pas :

    Pronostics.cs :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
     
    using SQLite;
    using System;
    using System.Collections.Generic;
    using System.Text;
     
    namespace GenTurfEvo.Models
    {
        [Table("")]
        public class Pronostics 
        {
            public string DateCourse { get; internal set; }
            public int NumReunion { get; internal set; }
            public string Hippodrome { get; internal set; }
            public int NumCourse { get; internal set; }
            public int MaBase { get; internal set; }
            public int Ch1 { get; internal set; }
            public int Ch2 { get; internal set; }
            public int Ch3 { get; internal set; }
            public int Ch4 { get; internal set; }
            public int Ch5 { get; internal set; }
            public int PCh1 { get; internal set; }
            public int PCh2 { get; internal set; }
            public int PCh3 { get; internal set; }
            public int PCh4 { get; internal set; }
            public int PCh5 { get; internal set; }
        }
    PronoRepository.cs :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
     
    using GenTurfEvo.Models;
    using SQLite;
    using System;
    using System.Collections.Generic;
    using System.Threading.Tasks;
     
    namespace GenTurfEvo.Repositories
    {
        internal class PronoRepository
        {
            private readonly SQLiteAsyncConnection cn;
            public string StatusMessage { get; set; }
            public PronoRepository(string dbPath)
            {
                cn = new SQLiteAsyncConnection(dbPath);
            }
            public async Task<List<Pronostics>> GetPronosticsAsync()
            {
                try
                {
                    return await cn.Table<Pronostics>().ToListAsync();
                }
                catch (Exception ex)
                {
                    StatusMessage = $"Pas de données disponibles\n Erreur : {ex.Message}";
                }
                return new List<Pronostics>();
            }
        }
    }
    Mon erreur de compilation se situe ici :
    App.xaml.cs :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    using System.IO;
    using Xamarin.Forms;
    using Xamarin.Essentials;
    using GenTurfEvo.Repositories;
    
    namespace GenTurfEvo
    {
        public partial class App : Application
        {
            private readonly string dbPath = Path.Combine(FileSystem.AppDataDirectory, "GenTurfEvo.db");
            public static PronoRepository PronoRepository { get; private set; }
    
    CS0053 Accessibilité incohérente*: le type de propriété 'PronoRepository' est moins accessible que la propriété 'App.PronoRepository' GenTurfEvo C:\NewTurf\GenTurfEvo\GenTurfEvo\App.xaml.cs 11 Actif
    public App() { InitializeComponent(); PronoRepository = new PronoRepository(dbPath); MainPage = new MainPage(); } protected override void OnStart() { } protected override void OnSleep() { } protected override void OnResume() { } } }
    MainPage.xaml.cs :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
     
    using System;
    using Xamarin.Forms;
     
    namespace GenTurfEvo
    {
        public partial class MainPage : ContentPage
        {
            public MainPage()
            {
                InitializeComponent();
            }
            private void OnClick(object sender, EventArgs e)
            {
                StackLayout parent = new StackLayout
                {
                    BackgroundColor = Color.Green,
                    Margin = new Thickness(5),
                    Padding = new Thickness(0)
                };
                parent.Children.Add(_ = new Frame
                {
                    BackgroundColor = Color.Blue,
                    Padding = new Thickness(0),
                    Content = new StackLayout
                    {
                        Orientation = StackOrientation.Horizontal,
                        Children =
                        {
                            new Label
                            {
                                Text="GenTurfEvo",
                                FontSize=Device.GetNamedSize(NamedSize.Title,typeof(Label)),
                                VerticalOptions= LayoutOptions.Center
                            }
                        }
                    }
                }
                );
                Content = parent;
            }
            private void OnPress(object sender, EventArgs e)
            {
                var button = (Button)sender;
                GenTurfEvoEntrer.BackgroundColor = Color.Green;
                button.Text = "Gagné";
            }
            private void OnRelease(object sender, EventArgs e)
            {
                var button = (Button)sender;
                button.Text = "GenTurfEvo";
                GenTurfEvoEntrer.BackgroundColor = Color.Blue;
            }
        }
    }
    D'avance merci de votre aide, Tchicken.

  2. #2
    Expert confirmé
    Homme Profil pro
    Responsable Données
    Inscrit en
    Janvier 2009
    Messages
    5 430
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Responsable Données

    Informations forums :
    Inscription : Janvier 2009
    Messages : 5 430
    Par défaut
    Bonjour,
    Le problème vient du fait que l'accessibilité la classe PronoRepository est "internal", alors que le membre PronoRepositiry de la classe publique App est "PUBLIC".
    Donc de l'extérieur de ton namespace, on peut instancier la classe, accéder au membre PronoRepository mais pas à son type, ce qui est incohérent.
    Il faut rendre la classe PronoRepository publique.

    Tatayo.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [XL-2007] Erreur de compilation : projet ou bibliothèque introuvable
    Par Chtik dans le forum Macros et VBA Excel
    Réponses: 5
    Dernier message: 15/07/2020, 20h28
  2. erreur de compilation projet
    Par timtof2011 dans le forum Excel
    Réponses: 1
    Dernier message: 17/01/2012, 14h32
  3. pb d'erreur de compilation projet ou bibliotheque introuvable
    Par zied.ellouze dans le forum VB 6 et antérieur
    Réponses: 1
    Dernier message: 28/06/2011, 19h20
  4. [XL-2000] Message d'erreur "Erreur de compilation:Projet ou bibliotheque introuvable"
    Par cubix dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 25/06/2010, 07h36
  5. [XL-2007] Erreur de compilation / Projet ou biblio introuvable
    Par cynoq dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 29/10/2009, 13h49

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo