What is the simplest way to verify that a pack uri can be found?
For example, given
pack://application:,,,Rhino.Mocks;3.5.0.1337;0b3305902db7183f;component/SomeImage.png
how would I check whether the image actually exists?
Cheers,
Berryl
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I couldn’t find a simple answer to this, so I wound up rolling my own code to accomplish three things with respect to image resources:
(1) have a string representation of a pack uri (databind)
(2) verify that the image is located where I think it is located (unit test)
(3) verify that the pack uri can be used to set an image (unit test)
Part of the reason this isn’t simple is because pack uri’s are a bit confusing at first, and come in several flavors. This code is for a pack uri that represents an image that is included in a VS assembly (either locally or a referenced assembly with a build action of ‘resource’. This msdn articles clarifies what that means in this context. You also need to understand more about assemblies and builds than might initially seem like a good time.
Hope this makes it easier for someone else. Cheers,
Berryl