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

Windows Presentation Foundation Discussion :

[VS2010][C#]MarkupExtension & Designer XAML


Sujet :

Windows Presentation Foundation

  1. #1
    Membre actif Avatar de zEndymion
    Homme Profil pro
    Responsable des applications
    Inscrit en
    Avril 2006
    Messages
    162
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Responsable des applications
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2006
    Messages : 162
    Points : 203
    Points
    203
    Par défaut [VS2010][C#]MarkupExtension & Designer XAML
    Bonjour,

    J'ai un petit pb avec le designer XAML j'utilise cette classe pour gérer les options selon le profil de l'utilisateur connecté :

    Code c# : 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
     
    namespace StkConsignation.business.Security
    {
     
        [MarkupExtensionReturnType(typeof(Visibility))]
        public  class AuthToVisibilityExtension:MarkupExtension
        {
     
            public string Operation { get; set; }
     
            public AuthToVisibilityExtension()
            {
                Operation = string.Empty;
            }
     
            public AuthToVisibilityExtension(string operation)
            {
                Operation = operation;
            }
     
            public override object ProvideValue(IServiceProvider serviceProvider)
            {
     
                if (string.IsNullOrEmpty(Operation))
                    return Visibility.Collapsed;
     
                if ( App.User.AuthorizedCtl.Contains(Operation))
                    return Visibility.Visible;
                return Visibility.Collapsed;
     
     
            }
     
        }
    }

    dans le XAML

    Code xaml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
     
    xmlns:op="clr-namespace:StkConsignation.business.Security"
     
    ...
    ..
    .
     
                        <MenuItem Header="{l:Reader Key=menuItem_Mailling}" Name="mnu_mailing" Click="mnu_mailing_Click" Visibility="{op:AuthToVisibility Operation=CAN_MAIL}" >
                            <MenuItem.Icon>
                                <Image Source="/StkConsignation;component/Ress/Icon/iconGUI_eMail.png" Width="25" />
                            </MenuItem.Icon>
                        </MenuItem>

    l'application complile et fonctionne sans problème mais j'ai l'erreur suivante en mode design :

    Erreur 77 Une exception a été levée par l'initialiseur de type pour StkConsignation.App'.



    La connexion nommée spécifiée est introuvable dans la configuration, n'est pas destinée à être utilisée avec le fournisseur EntityClient ou n'est pas valide.
    à System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
    à System.Data.EntityClient.EntityConnection..ctor(String connectionString)
    à System.Data.Objects.ObjectContext.CreateEntityConnection(String connectionString)
    à System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName)
    à StkConsignation.dao.STK_CONSIGNEntities..ctor() dans D:\Lib Programmation\StkConsignation\StkConsignation\dao\DataModel.Designer.cs:ligne 50
    à StkConsignation.App..cctor() dans D:\Lib Programmation\StkConsignation\StkConsignation\App.xaml.cs:ligne 20
    Et là , je suis tout sec ... et vous ?

  2. #2
    Membre expert
    Avatar de GuruuMeditation
    Homme Profil pro
    .Net Architect
    Inscrit en
    Octobre 2010
    Messages
    1 705
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Belgique

    Informations professionnelles :
    Activité : .Net Architect
    Secteur : Conseil

    Informations forums :
    Inscription : Octobre 2010
    Messages : 1 705
    Points : 3 568
    Points
    3 568
    Par défaut
    Ce genre d'erreur est souvent du au fait que la connectionstring d'entity se trouve dans un autre projet. Il est possible que le designer essaye d'instancier un contrôle qui dépend d'un entity Framework qui se trouve dans un autre projet. A l'exécution, ca peut marcher parc que tout est bien initialisé.
    Microsoft MVP : Windows Platform

    MCPD - Windows Phone Developer
    MCPD - Windows Developer 4

    http://www.guruumeditation.net

    “If debugging is the process of removing bugs, then programming must be the process of putting them in.”
    (Edsger W. Dijkstra)

  3. #3
    Membre actif Avatar de zEndymion
    Homme Profil pro
    Responsable des applications
    Inscrit en
    Avril 2006
    Messages
    162
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Responsable des applications
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2006
    Messages : 162
    Points : 203
    Points
    203
    Par défaut
    En effet il y a plusieurs projet dans la solution.

    Mais le modele EF et la connexion string sont dans le même projet. Celui ou l'erreur intervient.

  4. #4
    Membre expert
    Avatar de GuruuMeditation
    Homme Profil pro
    .Net Architect
    Inscrit en
    Octobre 2010
    Messages
    1 705
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : Belgique

    Informations professionnelles :
    Activité : .Net Architect
    Secteur : Conseil

    Informations forums :
    Inscription : Octobre 2010
    Messages : 1 705
    Points : 3 568
    Points
    3 568
    Par défaut
    EF et la connection string sont dans le projet ou il y a StkConsignation.App ?
    Microsoft MVP : Windows Platform

    MCPD - Windows Phone Developer
    MCPD - Windows Developer 4

    http://www.guruumeditation.net

    “If debugging is the process of removing bugs, then programming must be the process of putting them in.”
    (Edsger W. Dijkstra)

  5. #5
    Membre actif Avatar de zEndymion
    Homme Profil pro
    Responsable des applications
    Inscrit en
    Avril 2006
    Messages
    162
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : Responsable des applications
    Secteur : Industrie

    Informations forums :
    Inscription : Avril 2006
    Messages : 162
    Points : 203
    Points
    203
    Par défaut
    Complètement.

Discussions similaires

  1. WPF, XAML, Visual Studio 2010 Designer : exception non gérée
    Par nicopulse dans le forum Windows Presentation Foundation
    Réponses: 4
    Dernier message: 09/06/2010, 22h41
  2. DATASET Designer VS2010
    Par habibdu70 dans le forum Linq
    Réponses: 1
    Dernier message: 26/05/2010, 11h02
  3. pas de vue Design en Xaml ?
    Par CUCARACHA dans le forum Silverlight
    Réponses: 7
    Dernier message: 03/11/2009, 11h15
  4. [Expression Graphic Designer] Comment incorporer dans une form XAML ?
    Par pc152 dans le forum Windows Presentation Foundation
    Réponses: 14
    Dernier message: 12/08/2006, 09h25

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