Associated icons blank in OpenFileDialog

1.5k views Asked by At

I'm deploying an application built with VS 2010 Express edition via ClickOnce.

I have associated some file extensions using the options provided in the Publish section of the project's properties.

When I install the application, the associated file extension icons appear normally in Explorer but, when the user tries to open a file in my application, the associated icons appear blank.

File Explorer vs OpenFileDialog - Windows 7

The relative code section is the following:

Dim dialog As New OpenFileDialog
With dialog
    .AddExtension = True
    .CheckFileExists = True
    .CheckPathExists = True
    .DefaultExt = "pss"
    .FileName = String.Empty
    .Filter = "Data files|*.pss|All files (*.*)|*.*"
    .FilterIndex = 0
    .InitialDirectory = MySettings.SavePath
    .Multiselect = False
    .ValidateNames = True

    If .ShowDialog(Me) = Windows.Forms.DialogResult.OK Then

        OpenFile(.FileName)

    End If

End With

I was always under the impression that OpenFileDialog is a wrapper for Explorer, but for some reason the icons don't appear correct.

Does anyone have any idea how to correct the problem?

Edit: The behaviour is only relevant to Windows 7. Windows XP behaves normally.

2

There are 2 answers

0
Anax On BEST ANSWER

I forgot to change the included associated icons to:

Build action: Content
Copy to Output Directory: Always

I found this thanks to the manual updates, during which I was getting the error message "Object Reference not set to an instance of an object" during the updateCompleted event.

1
Harsh On

I believe you need to set the default view to thumbnail, so that the graphics appear for the pss files. You can check this by manually changing the view to thumbnail while running your application.

If changing the view to thumbnail shows the graphics then check the link below to achieve this: http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/571b39c2-0edf-4159-ac8d-1c059f69a978