Usercontrol et adobe reader ne marche pas en .exe

Fermé
methu97 Messages postés 4 Date d'inscription jeudi 22 novembre 2018 Statut Membre Dernière intervention 28 décembre 2018 - Modifié le 27 déc. 2018 à 11:26
methu97 Messages postés 4 Date d'inscription jeudi 22 novembre 2018 Statut Membre Dernière intervention 28 décembre 2018 - 28 déc. 2018 à 09:20
Bonjour,

Je suis actuellement en train de réaliser un projet sur blend en vb.net je travaille sur xaml.
Mon but est d'essayer d’afficher les pdf et j’ai tenté le web browser cependant il n’affiche pas les pdf qui ont des caractères donc pour éviter ce problème j’ai tenté une autre solution qui est d’utiliser le AdobeReader de winforms pour xaml

Pour ça j’ai dû créer un user control et dedans j’ai appelé AdobeReader, ensuite dans la page xaml j’ai créé un WindowsFormshost pour pouvoir appeler le usercontrol voici le code que j’utilise pour afficher :

 Imports System.Windows.Forms.Integration
Imports System.Windows.Forms.UserControl
Imports AcroPDFLib


Class MainWindow
    Private Sub Test_Click(sender As Object, e As RoutedEventArgs) Handles test.Click
        Dim GrandPageUsercontrol As New UserControl1()


        MsgBox("test")
        GrandPageUsercontrol.AxAcroPDF1.LoadFile("\\.pdf")

        Dim host = New WindowsFormsHost
        WindowsFormsHost1.Child = GrandPageUsercontrol
        Test_PDF.Children.Add(host)

    End Sub
End Class

Dans la partie l’usercontrol :
Public Class UserControl1
    Sub New()

        ' Cet appel est requis par le concepteur.
        InitializeComponent()

        ' Ajoutez une initialisation quelconque après l'appel InitializeComponent().

    End Sub


End Class
 

Le problème c’est que tout marche mais une fois que l’application est générée en .exe l’application crache sans aucune erreur.
A voir également:

4 réponses

cs_Le Pivert Messages postés 7903 Date d'inscription jeudi 13 septembre 2007 Statut Contributeur Dernière intervention 11 mars 2024 728
27 déc. 2018 à 09:49
0
Whismeril Messages postés 19028 Date d'inscription mardi 11 mars 2003 Statut Non membre Dernière intervention 24 avril 2024 931
27 déc. 2018 à 11:02
Bonjour Le Pivert.
Ton contrôle est un contrôle winform.
Methu a précisé qu’il travaille en XAML, donc WPF.
Il est assez chiant d’utliser un objet winform en WPF.
0
Whismeril Messages postés 19028 Date d'inscription mardi 11 mars 2003 Statut Non membre Dernière intervention 24 avril 2024 931
27 déc. 2018 à 11:15
Salut.

Il arrive en wpf, que ça plante sans t’afficher l’erreur.
J’ai un petit code qui permet de l’afficher, mais pas là sous la main.

En attendant, as tu essayé ça
https://www.syncfusion.com/wpf-ui-controls/pdf-viewer

0
methu97 Messages postés 4 Date d'inscription jeudi 22 novembre 2018 Statut Membre Dernière intervention 28 décembre 2018
27 déc. 2018 à 11:30
Salut,

Merci je vais essaye ça .
0
Whismeril Messages postés 19028 Date d'inscription mardi 11 mars 2003 Statut Non membre Dernière intervention 24 avril 2024 931
27 déc. 2018 à 19:29
0
Whismeril Messages postés 19028 Date d'inscription mardi 11 mars 2003 Statut Non membre Dernière intervention 24 avril 2024 931
27 déc. 2018 à 19:45
Je l'ai traduis en VB, en ajoutant un fichier de log, le message est parfois très long....

Dans le fichier Application.xaml.cs
		Protected Overrides Sub OnStartup(ByVal e As StartupEventArgs)
			' hook on error before app really starts
			AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf CurrentDomain_UnhandledException
			MyBase.OnStartup(e)
		End Sub

		Private Sub CurrentDomain_UnhandledException(ByVal sender As Object, ByVal e As UnhandledExceptionEventArgs)
			' put your tracing or logging code here (I put a message box as an example)
			MessageBox.Show(e.ExceptionObject.ToString())
			File.AppendAllText("Erreurs.log", e.ExceptionObject.ToString())
		End Sub


Avec
Imports System.IO
en haut du fichier
0
methu97 Messages postés 4 Date d'inscription jeudi 22 novembre 2018 Statut Membre Dernière intervention 28 décembre 2018
28 déc. 2018 à 09:20
Salut,

Merci pour le code.
J'ai ce message d'erreur qui est affiché "System.IO.FileNotFoundException: Impossible de charger le fichier ou l'assembly 'AxInterop.AcroPDFLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' ou une de ses dépendances.

du coup maintenant je vais chercher AxInterop.AcroPDFLib.dll pour voir si ça marche.
0