none
ImageList Generates ArgumentNullException in Word Application RRS feed

  • Question

  • I have created a Visual Studio Solution for a Word 2010 Application. The application extracts data from an Access 2010 database and puts it in a DataSet. The Visual Basic code extracts the data from the DataSet and fills textboxs and loads images into Word PictureContentControls. The application seems to work well when I target .NET Framework 4 Client Profile but when I target .NET Framework 3.5 SP1 so the Word document can be used in the XP environment I get an exception when trying to load a bitmap from and ImageList into a PictureContentControl. Below is the source:

    Line 1       u3row = dsUnits.Tables("Areas").Select("Areas = 'Personnel Building'")

    Line 2       PBOwner.Text = u3row(0).Item("Area_Owner").ToString()

    Line 3       PBAreaStatus.Image = StatGraphic.Images.Item(u3row(0).Item("Area_Status"))

    The ArgumentNullException is highlighting the last parenthese of line 3 which is the closing parenthese of the StatGraphic.Images.Item parameter. The exception also gives the following information:

    Value cannont be null.

    Parameter name: encoder

    When I check the project reference for System.Windows.Forms has changed from 4.0 to 2.0. The other .NET references are a mixture of 3.5 and 2.0 where previously all the System references were 4.0.

    As I stated before this code works fine for version 4.0 of the .NET Framework Client Profile but does not when I target version 3.5 SP1 Framework. Does anyone have any insight into this particular error. Thanks for any help you can give.

    Monday, November 26, 2012 1:53 PM

All replies

  • Hi Dana,

    Sorry for later respones.

    The application seems to work well when I target .NET Framework 4 Client Profile but when I target .NET Framework 3.5 SP1 so the Word document can be used in the XP environment I get an exception when trying to load a bitmap from and ImageList into a PictureContentControl.

    Did you recompile the project and didn't get any error on your side? 

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Monday, December 3, 2012 5:32 AM
    Moderator