locked
Lightswitch Silverlight Printing Problems RRS feed

  • Question

  • I am having troubles with a user being able to print a Customer Silverlight Control but everything works perfectly here..always.

    I have created a custom Silverlight Control for a report that needs printed.  This is just one record in a database and not a list of records.  I have a print button within the silverlight control that a user clicks on to print.  The code behind the button is as follows:

    Imports System.Windows.Printing
    Imports System.Windows.Data
    Imports System.Windows.Media.Imaging
    Imports System.Windows.Controls
    
    
    Partial Public Class APRvsRebate
        Inherits UserControl
        Private WithEvents pd As New PrintDocument()
    
        Public Sub New()
            InitializeComponent()
            PrintedDate.Text = DateTime.Today.ToShortDateString()
        End Sub
    
        Private Sub PrintButton_Click(sender As Object, e As System.Windows.RoutedEventArgs)
            AddHandler pd.PrintPage, AddressOf pd_PrintPage
            pd.Print([String].Format("Invoice Date: {0}", DateTime.Today.ToShortDateString()))
        End Sub
    
        Private Sub pd_PrintPage(sender As Object, e As PrintPageEventArgs)
            e.PageVisual = LayoutRoot
        End Sub
    End Class


    I can print everytime without issues, but this user will sometimes print okay but then other times will print a blank page.  This happens even when printing to XPS.  This users will keep the Lightswitch application open most of the day.  In doing so, will occassionally get a timeout login error and will need to log back into the application. It seems after doing this the blank pages begin to print...or even sometimes no printing at all, but also no error message at all.

    I had one image that was dynamically displayed and have since disabled that thinking it may be the issue, although, I did not disable this portion of the XAML...

        <UserControl.Resources>
            <converter:BytesToBitmapConverter x:Key="BytesToBitmapConverter" />
            <converter:ObjectToVisibility x:Key="ObjectToVisibility" />
            <converter:TrueFalseObjectToVisibility x:Key="TrueFalseObjectToVisibility" />
        </UserControl.Resources>

    Could this code be the issue in loading the converter?

    I am at a complete loss here and have been working at trying to fix this intermittent issue I can not replicate for two months now without any resolution.  I had posted a similar question once before with no help really.  Hopefully someone will see this post and give me a much needed and appreciated hand. :)

    Have a great day!

    Wednesday, October 1, 2014 1:26 AM

Answers

  • My solution so far has been to publish as an 'out of browser' app.  I was always deploying to Azure.  So far the OOB has seemed to have fixed the issue....fingers crossed.  Still very odd that it would happen for one user/one network.
    • Marked as answer by Angie Xu Thursday, October 23, 2014 3:18 AM
    Tuesday, October 21, 2014 9:52 AM

All replies

  • I thought we are suppose to have a response within 48 hours of posting if not already answered??????
    Monday, October 6, 2014 2:13 PM
  • I can print everytime without issues, but this user will sometimes print okay but then other times will print a blank page.  This happens even when printing to XPS.  This users will keep the Lightswitch application open most of the day.  In doing so, will occassionally get a timeout login error and will need to log back into the application. It seems after doing this the blank pages begin to print...or even sometimes no printing at all, but also no error message at all.

    Could you provide a scenario so that we can test this project?
    Monday, October 13, 2014 5:52 AM
  • Hi Voyagar12,

    Sometimes when you build your project in Visual Studio, the output will say that there are errors, but there doesn’t appear to be any apparent errors in the output it gives you.  It’s recommended to follow the steps below to turn the build output up. It will give some hints why this happens.

    In the Options window, find Projects and Solutions >> Build and Run. Find Diagnostic in the drop-down for MSBuild project build output verbosity. 

    At the same time you can use the code snippet below, and check whether it has same issue.

        <UserControl.Resources>
           
    <converter:BytesToBitmapConverter x:Key="BytesToBitmapConverter" />
           <!--
    <converter:ObjectToVisibility x:Key="ObjectToVisibility" /> -->
           <!--
    <converter:TrueFalseObjectToVisibility x:Key="TrueFalseObjectToVisibility" /> -->
       
    </UserControl.Resources>

    Please let me know if there is anything that I can do to help.

    Best regards,

    Angie


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, October 15, 2014 3:40 AM
  • I have, since first posting my message, attempted a few additional items.  I have created a new Azure Website.  This seemed to solve the issue for a time, but then a report came in that it was printing a blank again.  I then switched to yet another new Azure Website, went to the first tiered pay plan of the website and also switched to an "Out of Browser" lightswitch app.  I have no idea if any of this will help, but still waiting on reports it has not.  This is very difficult to diagnose because I am unable to replicate on my machines.  

    SharpLj, Since I am unable to replicate this myself, I am not sure how to give you a scenario to test.  I could give you a login to the app if you think that would help?  Or do you want/need something else?

    Angie, I am reluctant alter the code snippet at this point until I get another report that the page is printing blank again.  I see the only thing you have done is commented out the visibility.  I have lots of lines in my xaml that calls this so I would then assume I need to comment those out as well.  The next time there is a report of a blank page, I will do the commenting out.  

    Angie, changing the setting to Diagnostic...will that have any effect at all on what is uploaded to Azure Websites?  I am so reluctant to do anything that may further damage anything?  Again, especially when I am unable to replicate this blank page printing thing.  

    Have a great day and thanks for the responses!

    Wednesday, October 15, 2014 1:34 PM
  • Could running in XP Cause any serious issues with this?
    Wednesday, October 15, 2014 7:50 PM
  • Angie, changing the setting to Diagnostic...will that have any effect at all on what is uploaded to Azure Websites?  I am so reluctant to do anything that may further damage anything?  Again, especially when I am unable to replicate this blank page printing thing.  

    HI Voyagr12,

    Change the setting to Diagnostic, it is diagnostic method before you deploy your lightswitch application, it doesn't have bad influence on your application.  

    It's also recommended to deploy your LS application to Azure. Build, deploy and manage it on Azure, and check whether it still has same issue.

    Please let me know if there is anything that I can do to help.

    Best regards,

    Angie


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, October 21, 2014 9:49 AM
  • My solution so far has been to publish as an 'out of browser' app.  I was always deploying to Azure.  So far the OOB has seemed to have fixed the issue....fingers crossed.  Still very odd that it would happen for one user/one network.
    • Marked as answer by Angie Xu Thursday, October 23, 2014 3:18 AM
    Tuesday, October 21, 2014 9:52 AM