locked
Parameter is not valid exception RRS feed

  • Question

  • I get this error from my application, but not in the development environment (VS 2008).  I created an installer package and have installed it on two different XP machines with no problem.  However, on a Vista system when the application runs code to generate an image I get a "Parameter is not valid" exception.  I have no clue what could be causing this given the circumstances.  To generate the image I am creating a bitmap with a valid size and simply creating the graphic.  Since I can't repoduce the error in VS I don't have a way to troubleshoot this. Any ideas?
    Friday, March 27, 2009 7:17 PM

Answers

  • Okay, figure this one out.  I installed VS 2008 Standard on the Vista system and copied the project over.  After getting it setup properly it worked in the environment.  After that the installation also worked.  I have also installed the application on my home vista system which works fine as well.  So it was not so much a Vista problem as a problem on that Vista machine.  What do you think was the problem?
    Saturday, March 28, 2009 12:49 PM
  • it is great that the problem solve, it may be some of the .NET framework files or library that was missing, then when you installed vs2008, it fix the problem. that is my suggestion.

    kaymaf

    Saturday, March 28, 2009 2:40 PM

All replies

  • Hi randywheeler,

    It seems there is a problem in Vista related to graphics. It may work if you target x86 platform.

    To add configuration manager to menu:
    1. Click on Tools > Options
    2. Select Projects and Solutions
    3. Check the Show advanced build configurations option and click the OK button

    To target x86:

    1. Click on Build > Configuration Manager
    2. Click on the Platform dropdown for your project in the list and select <New...>
    3. In the Project Platform dialog select x86 from the new Platform dropdown and click OK
    Friday, March 27, 2009 8:21 PM
  • No luck.  It still won't work.  I will try the installation on another Vista system to see if it is pervasive.  If it is then I have a big problem.
    Friday, March 27, 2009 8:45 PM
  • hi randywheeler,

    can we see some code that generate the image?

    kaymaf

    Friday, March 27, 2009 8:53 PM
  •  
            Dim PrintAreaHeight, PrintAreaWidth, MarginLeft, MarginTop, Center As Int32  
            Dim MultiRecordFont As New Font("Arial", 6, FontStyle.Regular)  
            Dim g As Graphics = Nothing 
            Dim mybitmap As Bitmap = Nothing 
            With doctoprint.DefaultPageSettings  
                If doctoprint.PrintController.IsPreview Then  
                    MarginLeft = .Margins.Left  
                    MarginTop = .Margins.Top  
                Else  
                    MarginLeft = .Margins.Left - .PrintableArea.Left  
                    MarginTop = .Margins.Top - .PrintableArea.Top  
                End If  
                If Not .Landscape Then  
                    PrintAreaHeight = .PaperSize.Height - .Margins.Top - .Margins.Bottom  
                    PrintAreaWidth = .PaperSize.Width - .Margins.Left - .Margins.Right  
                    Center = PrintAreaWidth / 2  
                    mybitmap = New Bitmap(PrintAreaWidth, PrintAreaHeight)  
                    g = Graphics.FromImage(mybitmap)  
                Else  
                    PrintAreaWidth = .PaperSize.Height - .Margins.Left - .Margins.Right  
                    PrintAreaHeight = .PaperSize.Width - .Margins.Top - .Margins.Bottom  
                    Center = PrintAreaWidth / 2  
                    mybitmap = New Bitmap(PrintAreaWidth, PrintAreaHeight)  
                    g = Graphics.FromImage(mybitmap)  
                End If  
            End With  
            g.Clear(Color.White)  
     
    REM I am leaving out all of the graphics stuff  
     
            If Not MultiPage Then  
                e.Graphics.DrawImage(mybitmap, New Rectangle(MarginLeft, MarginTop, mybitmap.Width, mybitmap.Height))  
            Else  
                With doctoprint.DefaultPageSettings  
                    e.Graphics.DrawImage(mybitmap, New Rectangle(MarginLeft + MultiPageX * mybitmap.Width / RecordsPerPageX, MarginTop + MultiPageY * mybitmap.Height / RecordsPerPageY, mybitmap.Width / RecordsPerPageX, mybitmap.Height / RecordsPerPageY))  
                End With  
            End If  
     
    REM A lot of this may not make sense but I thought this is what would be important 
    Friday, March 27, 2009 9:00 PM
  • hi,

    Vista OS is sometimes weird, my suggestion is that, try to run the program from VS2008 on the vista machine with try and catch exception so that it maybe easy to figure it out. it may be GDI+ or .NET framework problem

    kaymaf
    Friday, March 27, 2009 9:39 PM
  • Okay, figure this one out.  I installed VS 2008 Standard on the Vista system and copied the project over.  After getting it setup properly it worked in the environment.  After that the installation also worked.  I have also installed the application on my home vista system which works fine as well.  So it was not so much a Vista problem as a problem on that Vista machine.  What do you think was the problem?
    Saturday, March 28, 2009 12:49 PM
  • it is great that the problem solve, it may be some of the .NET framework files or library that was missing, then when you installed vs2008, it fix the problem. that is my suggestion.

    kaymaf

    Saturday, March 28, 2009 2:40 PM