Hi,
I have a problem with image processing in XS App. I want to use an image as a post. Add image file (img100.jpg0 to the project resource and copy it to the Debug directory. The compilation runs OK, but an error occurs when the app is started (error screen is in attachment).
Juraj
image in XSharp app
image in XSharp app
Hi Juraj,
It's too hard to tell without seeing the code. Can you please zip the solution and post it here so we can have a look?
Chris
It's too hard to tell without seeing the code. Can you please zip the solution and post it here so we can have a look?
Chris
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
image in XSharp app
Hi Chris
sample project in atachments
Juraj
sample project in atachments
Juraj
image in XSharp app
Hi Chris
Attachment file size exceed limit allowed by configuration.
I can send a zip file to a mail?
Juraj
Attachment file size exceed limit allowed by configuration.
I can send a zip file to a mail?
Juraj
image in XSharp app
Hi Juraj,
Yes, please send it to chris (at) xsharp. eu. I only suggested sending it here so maybe others could step in as well and provide their input on this.
But is it really that large? I thought it was just a test project. If it isn't, then please better try to reproduce the problem in a small new test project, using the same method to include the image, as in your original app. Does this show the same error at runtime? If yes, please send this one instead.
Chris
Yes, please send it to chris (at) xsharp. eu. I only suggested sending it here so maybe others could step in as well and provide their input on this.
But is it really that large? I thought it was just a test project. If it isn't, then please better try to reproduce the problem in a small new test project, using the same method to include the image, as in your original app. Does this show the same error at runtime? If yes, please send this one instead.
Chris
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
image in XSharp app
Hi Chris
I send sample project to chris@xsharp.eu. I use VS Community 2017 ver. 15.3.5. In VS wpf editor work correctly, also "Bulild project" output is OK (see attachment), error show at runtime.
Juraj
I send sample project to chris@xsharp.eu. I use VS Community 2017 ver. 15.3.5. In VS wpf editor work correctly, also "Bulild project" output is OK (see attachment), error show at runtime.
Juraj
image in XSharp app
Hi Juraj,
Thanks for the file! It was too large because the obj and debug folders were large, but those are not needed, I deleted them and zipped the solution again and I am attaching it to this message, so others can have a look as well if they want.
I could reproduce the problem here and searched online for the error message ("IOException cannot locate resource ..."), this is what I found:
https://stackoverflow.com/questions/119 ... -the-image
the suggested solution in there is to go to the image item in the Solution Explorer, right click and select Properties, then change the BuildAction property to "Resource". Rebuild and run, now it should work ok.
It looks good here now, and also please note that you do not need to include the image file in the folder together with your .exe, the image gets embedded inside the .exe, so no need to do anything else.
Chris
Thanks for the file! It was too large because the obj and debug folders were large, but those are not needed, I deleted them and zipped the solution again and I am attaching it to this message, so others can have a look as well if they want.
I could reproduce the problem here and searched online for the error message ("IOException cannot locate resource ..."), this is what I found:
https://stackoverflow.com/questions/119 ... -the-image
the suggested solution in there is to go to the image item in the Solution Explorer, right click and select Properties, then change the BuildAction property to "Resource". Rebuild and run, now it should work ok.
It looks good here now, and also please note that you do not need to include the image file in the folder together with your .exe, the image gets embedded inside the .exe, so no need to do anything else.
Chris
- Attachments
-
- WPFImageSample.zip
- (1.51 MiB) Downloaded 56 times
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
-
- Posts: 248
- Joined: Fri Oct 14, 2016 7:09 am
image in XSharp app
Not really addressing the actual issue here but AFAIK using Build Action Resource will physically embed the file into the assembly.
Using Content creates a reference to the file, but doesn't physically embed it. This means that if you use Content, you have to distribute the external files, but it does have the advantage that you can change the files without recompiling.
So if you have for example some images that need to be updated periodically for whatever reason, without changes to the source code itself, you can use Content, otherwise Resource is simpler.
Nick
Using Content creates a reference to the file, but doesn't physically embed it. This means that if you use Content, you have to distribute the external files, but it does have the advantage that you can change the files without recompiling.
So if you have for example some images that need to be updated periodically for whatever reason, without changes to the source code itself, you can use Content, otherwise Resource is simpler.
Nick
image in XSharp app
Hi Chris, Nick
Thank you for your reply.
Chris solution is ok but i would like if the images were not in exe, as Nick wrote, so I would like a solution in this way.
If the xaml code I use in C#, it works, the same xamlcode in X# does not work at runtime.
Juraj
Thank you for your reply.
Chris solution is ok but i would like if the images were not in exe, as Nick wrote, so I would like a solution in this way.
If the xaml code I use in C#, it works, the same xamlcode in X# does not work at runtime.
Juraj
image in XSharp app
Hi Juraj,
if you would like to keep your images distinct from the executable, you should load them manually at runtime.
I'm using the following code in my DoorConfigurator to display the images of the doors and the relative accessories:
I have a user control that receives the bitmap file name via databinding from the ViewModel (it is a MVVM application) and displays it.
Wolfgang
if you would like to keep your images distinct from the executable, you should load them manually at runtime.
I'm using the following code in my DoorConfigurator to display the images of the doors and the relative accessories:
Code: Select all
oBitmapImage := BitmapImage{}
oBitmapImage:BeginInit()
oBitmapImage:UriSource := Uri{ cBitmapName }
oBitmapImage:EndInit()
_oImage:Source := oBitmapImage
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it