Exception thrown in a ClickOnce installation

Hi again,

Sorry, but I have another ClickOnce problem. My program runs without exception in the development environment, but the ClickOnce RUN version throws an exception in the form.Load event.

PrivateSub Form1_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMyBase.Load
Try
Dim fileStrAsString ="..\Images\"
doorPic(0) = Image.FromFile(fileStr +"Door1.gif")
doorPic(1) = Image.FromFile(fileStr +
"Door1S.gif.")
doorPic(2) = Image.FromFile(fileStr +
"Door2.gif")
doorPic(3) = Image.FromFile(fileStr +
"Door2S.gif")
doorPic(4) = Image.FromFile(fileStr +
"Door3.gif")
LoadPic(1, 0)
LoadPic(2, 2)
LoadPic(3, 4)
TextBox3.Text = Msg1
Catch exAs Exception
MsgBox(
"Load Exception: " & ex.Message)
EndTry
EndSub

The messagebox says, "Load Exception: ..\Images\Door1.gif" After the message box is cleared, the form opens and displays the 3 GIFs that are loaded in the LoadPic subroutine.The application has been deployed to a website.I can open the website and see that ClickOnce has created a folder Images and it contains allthe GIFs in the application.

Your insight as to the cause of this problem would be greatly appreciated, thanks.

[5653 byte] By [GrandpaB] at [2007-12-21]
# 1

Please can you provide a full description of the exception being thrown.

What you showing is not the complete exception message and so its difficult to determine what exception is occuring when trying to run the form load procedure. Also what does LoadPic method do. If youve got a problem in here and you dont have any exception handling then it will bubble up to here and throw the exception.

spotty at 2007-9-10 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 2

Right on spotty.

Grandpa, is there an inner exception?

Is the file there?

ReneeC at 2007-9-10 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 3

I'm not sure exactly whats happening with the program as such but it may be that you are trying to access resources that are not copied to the deployment directory. If the images never change you should really add them to the project, that way they will go wherever the finished program goes. Otherwise make sure all files are included in the compiler.

Just a thought.

PsychUK at 2007-9-10 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 4

Thanks, for your replies.

Spotty, I spent some time looking into how to get a full description of the exception.The only thing that I know to do is display ex.message in a MsgBox.The complete message is, Load Exception: ..\Images\Door1.gifIf there is something more that I could do, please let me know.

ReneeC, please explain what you mean by an inner exception.I believe that the GIFs have been uploaded to the server.Using Dreamweaver, I have examined the threedoor folder that VB’s ClickOnce placed on my website.That folder contains a subfolder Images and in that folder are all my GIFs with a deploy extension, ie Door1.gif.deploy.

PsychUK, I think the information in the previous paragraph makes me believe that the resources have uploaded.The application also uploads an icon to the Images folder and it displays correctly when the form opens.

I republished the application and moved the Try-Catch block so that it just initializes the doorPic() array.I get the same error, however in this release no images are displayed.As you requested, I have included the LoadPic subroutine.

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Dim fileStr As String = "..\Images\"
doorPic(0) = Image.FromFile(fileStr + "Door1.gif")
doorPic(1) = Image.FromFile(fileStr + "Door1S.gif.")
doorPic(2) = Image.FromFile(fileStr + "Door2.gif")
doorPic(3) = Image.FromFile(fileStr + "Door2S.gif")
doorPic(4) = Image.FromFile(fileStr + "Door3.gif")
Catch ex As Exception
MsgBox("Load Exception: " & ex.Message)
End Try
LoadPic(1, 0)
LoadPic(2, 2)
LoadPic(3, 4)
TextBox3.Text = Msg1
End Sub

Sub LoadPic(ByVal Door As Integer, ByVal i As Integer)
Select Case Door
Case 1
pbDoor1.Image = doorPic(i)
pbDoor1.Tag = i
Case 2
pbDoor2.Image = doorPic(i)
pbDoor2.Tag = i
Case 3
pbDoor3.Image = doorPic(i)
pbDoor3.Tag = i
End Select
End
Sub

Thanks again to one and all for your assistance.

GrandpaB at 2007-9-10 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 5

Are the images being loaded from a folder on your user's local computer? Or are they being loaded from another computer/server on a network? It could be a simple permissions problem if the folder that contains the images are on a shared network server. As for your error I would change it to : MsgBox("Load Error: " & ex.Message + " " + ex.Source)

That will give you more details on the error itself.

james

aka:Trucker

Trucker at 2007-9-10 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 6

What OS is it running on? Perhaps the message box is truncating the message. in any case, use the MessageBox.Show method, instead of the old MsgBox method.

Why not put the images in the EXE as resources?

the ex exception object has an InnerExeception property. You'll need to hande the error a bit more gracefully to figure out what's going on by looking at that InnerException.

SJWhiteley at 2007-9-10 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 7

Again, thanks for the helping hand,

I've changed MsgBox to MessageBox.Show and I've added ex.source to the message box string. The error message now reads:

Load Exception: ..\Images\Door1.gif System.Drawing

I'll have to do some studying to learn about the InnerException property. I am running the application on my development system and its OS is XP Professional. I added the folder, Images, to my project and then added the GIF files to the Images folder. The application ran, error free, on my system. I then clicked once on ClickOnce to deploy it to my website. Everything work as advertised until I ran the deployed application from my website.

GrandpaB at 2007-9-10 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 8

I believe the problem is in your ClickOnce Deployment Configuration. I am not totally familiar with using ClickOnce Deployment from a website and running an application from one. So, I cannot give you many suggestons other than to look over your ClickOnce Deployment setup carefully. I would go into Help and look in the "How Do I" section and Select the "Publish A Click Once Application" section and then the section for "Publishing to the Web". There are other sections that explain including Folders and Files with your ClickOnce Deployment and how to configure them for different types of installations.

I am willing to bet that is where your problem is coming from.........a mis-configured deployment. I do hope you get it going. Maybe, someone who is more familiar with ClickOnce Deployment will chime in here and offer some advice.

james

aka:Trucker

Edit: Go back to the Main MSDN Forums Index here and scroll down to the Windows Forms Section and there is a sub-section titled: ClickOnce Deployment and Setup. I would be willing to bet you can find the answer to your problem right there.

Trucker at 2007-9-10 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 9

This is a shot in the dark, but, filenames in most web page server environments are case-sensitive whereas on the PC they are not.

Worth checking

TallDude at 2007-9-10 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 10

Can you show us the code thats in the LoadPic function.

I think this may be relevent here.

spotty at 2007-9-10 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 11

Trucker,

Thanks for your input. I clicked the Publish tab on the Application Properties. I then clicked the "Application Files" button. There were 10 files listed in the "Application Files" window. There was threedoor.exe, threedoor.ico and 8 GIF files. All the files had a Publish Status of Include(auto), and a Download Group of (Required). This is a complete listing of all the files the application uses. The "Prerequisites" button had only ".NET Framwork 2.0" checked.

I have done some checking on the ClickOnce Deployment and Setup Forum. So far I have not seen a posting that is appliciable. I am tempted to re-post on that forum, but I'd like to noodle the problem a bit longer and hope the the VB Express folks can help steer me in the right direction.

GrandpaB at 2007-9-10 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 12

Thanks for the good ideas.

Tall Dude, my initial deployment used “images” in my code, whereas the file folder’s name was “Images.”I knew that I had solved the problem; silly me!I think I’ve got all the capitalization consistent.

Spotty, I did include the LoadPic code in an earlier post today.I doubt that the problem resides there.In that post I also changed the Try-Catch block so that it did not include the calls to the LoadPic subroutine.The error remained unchanged with this version of the program.

I had a thought (don’t laugh).Some of the GIFs are animated.The Door1S.gif and Door2S.gif GIFs are animated.The Try-Catch block seems to throw an exception with the statement that includes, Door1.gif, a non-animated GIF.This is probably not the cause of the error, but what the heck, I’ll give it a shot.

GrandpaB at 2007-9-10 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 13

Stranger things have happened!! I would comment out the code for the gif that it is hanging on and see if it works. It would be something if that were the problem.

james

aka:Trucker

Trucker at 2007-9-10 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 14

Trucker,

Well, I eliminated the animated GIFs and I commented out the doorPic(0) and doorPic(1) statements; the error remains, but it now whines about ..\Images\Door2.gif. While making those changes I noticed an error in the doorPic(1) statement! In the file name there was an extra period, "Door1S.gif." I knew that eliminating this period would be the solution to my problem, but no such luck. Speaking about whine, I'll stop whining, have supper and a glass of wine, or maybe two!

Does the new ex.source = System.Drawing mean anything that could help with my problem? After supper I'll try the suggestion to make the GIFs resources.

GrandpaB at 2007-9-10 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...