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

VB.NET Discussion :

Erreur BC40056 sur Imports System.Windows.Documents


Sujet :

VB.NET

  1. #1
    Membre actif
    Profil pro
    Inscrit en
    Février 2007
    Messages
    760
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 760
    Points : 208
    Points
    208
    Par défaut Erreur BC40056 sur Imports System.Windows.Documents
    Bonsoir à tous et à toutes,
    J'ai un problème sous VS 2022, quand je veux importer :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Imports System.Windows.Documents
    J'ai l'erreur suivante :
    BC40056: Namespace or type specified in the Imports '<qualifiedelementname>' doesn't contain any public member or cannot be found
    Si quelqu'un a une idée, mon projet est en vb.net WinForm

  2. #2
    Membre expérimenté
    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    1 126
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : France

    Informations forums :
    Inscription : Septembre 2010
    Messages : 1 126
    Points : 1 636
    Points
    1 636
    Par défaut
    Tu as quoi comme Framework cible du projet ?

  3. #3
    Expert confirmé
    Avatar de popo
    Homme Profil pro
    Analyste programmeur Delphi / C#
    Inscrit en
    Mars 2005
    Messages
    2 674
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Analyste programmeur Delphi / C#
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2005
    Messages : 2 674
    Points : 5 259
    Points
    5 259
    Par défaut
    Il te manque la référence à "PresentationFramework"

  4. #4
    Membre actif
    Profil pro
    Inscrit en
    Février 2007
    Messages
    760
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 760
    Points : 208
    Points
    208
    Par défaut
    Citation Envoyé par umfred Voir le message
    Tu as quoi comme Framework cible du projet ?
    *********************************************
    Merci,
    Je n'arrive pas à voir la version du Framework dans VS, j'ai lu dans la doc de regarder dans l'explorateur de Solutions qui me donne ça :
    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
    <Project Sdk="Microsoft.NET.Sdk">
    
      <PropertyGroup>
        <OutputType>WinExe</OutputType>
        <TargetFramework>net8.0-windows</TargetFramework>
        <StartupObject>Sub Main</StartupObject>
        <UseWindowsForms>true</UseWindowsForms>
        <MyType>WindowsForms</MyType>
      </PropertyGroup>
    
      <ItemGroup>
        <Import Include="System.Data" />
        <Import Include="System.Drawing" />
        <Import Include="System.Windows.Forms" />
      </ItemGroup>
    
      <ItemGroup>
        <Compile Update="My Project\Application.Designer.vb">
          <DesignTime>True</DesignTime>
          <AutoGen>True</AutoGen>
          <DependentUpon>Application.myapp</DependentUpon>
        </Compile>
      </ItemGroup>
    
      <ItemGroup>
        <None Update="My Project\Application.myapp">
          <Generator>MyApplicationCodeGenerator</Generator>
          <LastGenOutput>Application.Designer.vb</LastGenOutput>
        </None>
      </ItemGroup>
    
    </Project>
    peut être que c'est <TargetFramework>net8.0-windows</TargetFramework> çà peut te donner une idée

    J'arrive pas non plus à rajouter la référence à "PresentationFramework"

  5. #5
    Expert confirmé
    Avatar de popo
    Homme Profil pro
    Analyste programmeur Delphi / C#
    Inscrit en
    Mars 2005
    Messages
    2 674
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Analyste programmeur Delphi / C#
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2005
    Messages : 2 674
    Points : 5 259
    Points
    5 259
    Par défaut
    Tu as créé une application Winform.

    PresentationFramework et par extension le namespace System.Windows.Documents font partie de WPF.

  6. #6
    Expert éminent sénior Avatar de Pol63
    Homme Profil pro
    .NET / SQL SERVER
    Inscrit en
    Avril 2007
    Messages
    14 154
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Puy de Dôme (Auvergne)

    Informations professionnelles :
    Activité : .NET / SQL SERVER

    Informations forums :
    Inscription : Avril 2007
    Messages : 14 154
    Points : 25 072
    Points
    25 072
    Par défaut
    ce namespace ne fait pas partie de windows forms (c'est du wpf)
    si tu as trouvé un bout de code sur internet il n'est pas compatible avec ton projet

    c'est pour faire quoi ?
    Cours complets, tutos et autres FAQ ici : C# - VB.NET

  7. #7
    Membre actif
    Profil pro
    Inscrit en
    Février 2007
    Messages
    760
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 760
    Points : 208
    Points
    208
    Par défaut
    Bonjour et merci,
    C'est pour récupérer du texte provenant d'un controle RichTextBox en cliquant sur un bouton j'ai récupéré cette fonction sur le net :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    Private Function StringFromRichTextBox(ByVal rtb As RichTextBox) As String
        ' TextPointer to the start of content in the RichTextBox.
        ' TextPointer to the end of content in the RichTextBox.
        Dim textRange As New TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd)
     
        ' The Text property on a TextRange object returns a string
        ' representing the plain text content of the TextRange.
        Return textRange.Text
    End Function
    et ici New TextRange m'indique l'erreur BC30002: Type '<typename>' is not defined j'ai vu que la classe TextRange :
    Définition

    Espace de noms:
    System.Windows.Documents
    J'ai fait : Imports System.Windows.Documents et c'est là que j'ai eu l'erreur BC40056

  8. #8
    Expert éminent sénior Avatar de Pol63
    Homme Profil pro
    .NET / SQL SERVER
    Inscrit en
    Avril 2007
    Messages
    14 154
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Puy de Dôme (Auvergne)

    Informations professionnelles :
    Activité : .NET / SQL SERVER

    Informations forums :
    Inscription : Avril 2007
    Messages : 14 154
    Points : 25 072
    Points
    25 072
    Par défaut
    trouve la fonction en windows forms pour faire ça
    à priori ca serait juste rtb.Text
    Cours complets, tutos et autres FAQ ici : C# - VB.NET

  9. #9
    Membre expérimenté
    Profil pro
    Inscrit en
    Septembre 2010
    Messages
    1 126
    Détails du profil
    Informations personnelles :
    Âge : 45
    Localisation : France

    Informations forums :
    Inscription : Septembre 2010
    Messages : 1 126
    Points : 1 636
    Points
    1 636
    Par défaut
    Citation Envoyé par xeron33 Voir le message
    *********************************************
    Merci,
    Je n'arrive pas à voir la version du Framework dans VS, j'ai lu dans la doc de regarder dans l'explorateur de Solutions qui me donne ça :
    Tu y as accès dans les propriétés du projet sinon

  10. #10
    Membre actif
    Profil pro
    Inscrit en
    Février 2007
    Messages
    760
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2007
    Messages : 760
    Points : 208
    Points
    208
    Par défaut
    Citation Envoyé par Pol63 Voir le message
    trouve la fonction en windows forms pour faire ça
    à priori ca serait juste rtb.Text
    ****************************************
    Merci de ton aide, oui j'ai trouvé tout simplement :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    Private Function StringFromRichTextBox(ByVal rtb As RichTextBox) As String
        Return RichTextBox1.Text
    End Function
    puis pour rajouter le texte à la fin du fichier :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim inputString As String = StringFromRichTextBox(RichTextBox1)
        My.Computer.FileSystem.WriteAllText(
          "C:\Users\Documents\Module_Program_VB.txt", inputString, True)
    End Sub
    A+

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

Discussions similaires

  1. Réponses: 1
    Dernier message: 19/02/2012, 14h43
  2. Stretch horizontal sur un System.Windows.Controls.Image
    Par la_urre dans le forum Windows Phone
    Réponses: 2
    Dernier message: 27/07/2011, 16h27
  3. Comment modéliser les activités sur le système windows
    Par masterx_goldman dans le forum Windows
    Réponses: 1
    Dernier message: 01/10/2010, 01h12
  4. Erreur dans l'assembly system.windows
    Par brad63 dans le forum Windows Presentation Foundation
    Réponses: 1
    Dernier message: 09/01/2010, 15h36
  5. System Windows.Documents introuvable
    Par TaymouWan dans le forum C#
    Réponses: 3
    Dernier message: 26/03/2009, 09h08

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