Problem publishing my program
Problem publishing my program
Problem publishing my program
Problem publishing my program
Problem publishing my program
Problem publishing my program Problem publishing my program Problem publishing my program Problem publishing my program Problem publishing my program Problem publishing my program Problem publishing my program Problem publishing my program
Problem publishing my program Problem publishing my program
Problem publishing my program
Go Back  Xtreme Visual Basic Talk > > > Problem publishing my program


Reply
 
Thread Tools Display Modes
  #1  
Old 03-02-2010, 10:03 AM
jpaugh78's Avatar
jpaugh78 jpaugh78 is offline
Senior Contributor
 
Join Date: Dec 2003
Location: Columbus, Ohio USA
Posts: 1,129
Default Problem publishing my program


Hello everybody! Hopefully I can explain my problem....

I'm working on a Casino program, and I have the first game working. I'm trying to send the program to a friend so he can play around with it and give me some feedback. The best I've gotten so far, was that he was able to install the files, but when the cards are dealt, he gets errors saying that the program cannot find the pictures.

My root directory has a folder that has all the pictures in it.

My Card Game\cards\Standard\[All the cards are in here]

Here is an example of how I'm displaying the cards:

Code:
        
Dim newcards As New PictureBox
newcards.Location = New Point(playerHand1X, playerHand1Y)
newcards.Width = 69
newcards.Height = 95
newcards.SizeMode = PictureBoxSizeMode.StretchImage
newcards.Image = System.Drawing.Image.FromFile _
("C:\vb08sbs\My Card Games\cards\Standard\" & cardDeck.Item(1) & ".jpg") '<-----How I access the picture
Blackjack.Controls.Add(newcards)
newcards.BringToFront()
cardDeck.Remove(1)
The program works fine for me when I run it, but I must be missing a step when I publish the files, since he is getting those errors. Any help would be appreciated.

*Edit* I'm using Visual Basic Studio 2008
__________________
Did you Google your question before posting it here? Remember, Google is your friend. ;)
Reply With Quote
  #2  
Old 03-02-2010, 10:38 AM
PlausiblyDamp's Avatar
PlausiblyDampProblem publishing my program PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

Has your friend installed the game into exactly the same location it is running from on your computer? You have hard coded the c:\vb08sbs..... path into the executable so if your friend is running it from another location it will not find the files.

You might be better off either looking relative to the location of the executable...
Code:
Dim s As String = Application.StartupPath & "cards\Standard\" & cardDeck.Item(1) & ".jpg"  'should be close to what you need
or even embedding the images as resources so there are no extra files to worry about.
Reply With Quote
  #3  
Old 03-02-2010, 11:26 AM
jpaugh78's Avatar
jpaugh78 jpaugh78 is offline
Senior Contributor
 
Join Date: Dec 2003
Location: Columbus, Ohio USA
Posts: 1,129
Default

If I embed them as resources, how would I go about accessing them from my program?
__________________
Did you Google your question before posting it here? Remember, Google is your friend. ;)
Reply With Quote
  #4  
Old 03-02-2010, 12:47 PM
PlausiblyDamp's Avatar
PlausiblyDampProblem publishing my program PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

http://www.xtremedotnettalk.com/showthread.php?t=83574 - a quick sample I did years ago on xtremedotnettalk, it should still work the same however.
Reply With Quote
  #5  
Old 03-03-2010, 08:00 AM
jpaugh78's Avatar
jpaugh78 jpaugh78 is offline
Senior Contributor
 
Join Date: Dec 2003
Location: Columbus, Ohio USA
Posts: 1,129
Default

Quote:
Originally Posted by PlausiblyDamp View Post
http://www.xtremedotnettalk.com/showthread.php?t=83574 - a quick sample I did years ago on xtremedotnettalk, it should still work the same however.
I downloaded that code and have been toying around with embedding to work in my program, but I can't seem to get it to work yet.

Your code:
Code:
Dim myAssem As [Assembly]
myAssem = [Assembly].GetExecutingAssembly()
Dim s As System.IO.Stream
s = myAssem.GetManifestResourceStream("EmbeddedResources.logo.gif")

'as it's an image we can be lazy...
PictureBox1.Image = New Bitmap(s)
Would there be a different naming convention if I'm using Jpeg's? Because when I run my program I'm getting an error saying that the stream is null.
__________________
Did you Google your question before posting it here? Remember, Google is your friend. ;)
Reply With Quote
  #6  
Old 03-03-2010, 09:00 AM
PlausiblyDamp's Avatar
PlausiblyDampProblem publishing my program PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

Should still work. I will have a look at the code again in an hour or so and see if I can see any reason it would fail. One thing to be careful with though is the file names and how you to refer to them are case sensitive.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags

Last edited by PlausiblyDamp; 03-03-2010 at 09:09 AM.
Reply With Quote
  #7  
Old 03-03-2010, 02:50 PM
jpaugh78's Avatar
jpaugh78 jpaugh78 is offline
Senior Contributor
 
Join Date: Dec 2003
Location: Columbus, Ohio USA
Posts: 1,129
Default

The only thing that could be happening, is that maybe because of the way I'm storing the variables, that I have to call the resources a different way.

When I make the deck of cards, I store the data in a collection. So when I deal a card, I pull the data from the first position in the collection:

Code:
picturebox1.Image = System.Drawing.Image.FromFile _
("C:\vb08sbs\My Card Games\cards\Standard\" & cardDeck.Item(1) & ".jpg")
So when I use your code to do the same thing, my code looks like:
Code:
'I put all these at the top of the module, where they are supposed to go
Imports System.Reflection
Public myAssem As [Assembly]
Public s As System.IO.Stream


'Then I put these in the Function where I draw my cards:
s = myAssem.GetManifestResourceStream("EmbeddedResources." & cardDeck.Item(1) & ".jpg")
newcards.Image = New Bitmap(s)
__________________
Did you Google your question before posting it here? Remember, Google is your friend. ;)
Reply With Quote
  #8  
Old 03-03-2010, 04:01 PM
PlausiblyDamp's Avatar
PlausiblyDampProblem publishing my program PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

In the line
Quote:
Originally Posted by jpaugh78 View Post
Code:
s = myAssem.GetManifestResourceStream("EmbeddedResources." & cardDeck.Item(1) & ".jpg")
newcards.Image = New Bitmap(s)
what is the value of the string "EmbeddedResources." & cardDeck.Item(1) & ".jpg" and does it match the name of the original file?

As a test have you tried hard coding a path into the application to a file you know exists just to see if that is the problem?

I just ran my old sample after compiling under VS 2008 both against .Net 2 and 3.5 and it worked fine on both occasions.


The imports are fine at the top though, doing them there simply means they are only in effect for the one source file rather than the entire project.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #9  
Old 03-03-2010, 04:27 PM
jpaugh78's Avatar
jpaugh78 jpaugh78 is offline
Senior Contributor
 
Join Date: Dec 2003
Location: Columbus, Ohio USA
Posts: 1,129
Default

Quote:
Originally Posted by PlausiblyDamp View Post
In the line

what is the value of the string "EmbeddedResources." & cardDeck.Item(1) & ".jpg" and does it match the name of the original file?

As a test have you tried hard coding a path into the application to a file you know exists just to see if that is the problem?
The program works fine when I'm pointing to a picture file that does exist. My game is working fine as far as that is concerned. But when I try to save the pictures as resources, then access them that way, is when I'm getting the null error.

If the picture I am accessing is named 2S.jpg (2 of spades), would I say:

Code:
s = myAssem.GetManifestResourceStream("EmbeddedResources.2S.jpg")
picturebox1.image = New Bitmap(s)
Quote:
Originally Posted by PlausiblyDamp View Post
I just ran my old sample after compiling under VS 2008 both against .Net 2 and 3.5 and it worked fine on both occasions.
Your samples work fine for me. I just couldn't change it to work for my program to access my pictures.
__________________
Did you Google your question before posting it here? Remember, Google is your friend. ;)
Reply With Quote
  #10  
Old 03-03-2010, 04:46 PM
PlausiblyDamp's Avatar
PlausiblyDampProblem publishing my program PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

You would need to change the EmbeddedResources part of the filename to reflect your application's root namespace (under VB this defaults to the project name). If you application is called CardGame1 then the resource name would be
Code:
CardGame1.2s.jpg
Hope that helps.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #11  
Old 03-03-2010, 04:49 PM
jpaugh78's Avatar
jpaugh78 jpaugh78 is offline
Senior Contributor
 
Join Date: Dec 2003
Location: Columbus, Ohio USA
Posts: 1,129
Default

Quote:
Originally Posted by PlausiblyDamp View Post
You would need to change the EmbeddedResources part of the filename to reflect your application's root namespace (under VB this defaults to the project name). If you application is called CardGame1 then the resource name would be
Code:
CardGame1.2s.jpg
Hope that helps.
Heh, I figured it would be something stupid like that. I thought the EmbeddedResources part was the naming convention for it, since I had never used the resources.

[facepalm]

It took me a bit to get it working, since the name of my project was "My Card Games". I forgot that you have to replace spaces with underscores in file names.

In the end, this is what ended up working:
Code:
s = myAssem.GetManifestResourceStream("My_Card_Games." & cardDeck.Item(1) & ".jpg")
newcards.Image = New Bitmap(s)
Thanks for being patient and helping me out. [High Five]
__________________
Did you Google your question before posting it here? Remember, Google is your friend. ;)

Last edited by jpaugh78; 03-03-2010 at 05:47 PM.
Reply With Quote
Reply

Tags
embedded resource


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Problem publishing my program
Problem publishing my program
Problem publishing my program Problem publishing my program
Problem publishing my program
Problem publishing my program
Problem publishing my program Problem publishing my program Problem publishing my program Problem publishing my program Problem publishing my program Problem publishing my program Problem publishing my program
Problem publishing my program
Problem publishing my program
 
Problem publishing my program
Problem publishing my program
 
-->