I have built a web service pull data off from one application, which in turn links to another application's web service. However, when I look at one of the data types, which happens to be a list object, Visual Studio shows it as an array.
Can someone please advise me how I can use the meta data to correct this to a list object, or if there is another way to correct this?
It returns an array because a web service has nothing to do with Microsoft technologies - they are intended for other platforms as well. This means that you can't return a List return because it's a generic, which isn't allowed in web services. If you really need to use the return type in a generic list, you simply need to add the items in using the following logic:
List<MyObject> list = new List<MyObject>();
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
Have you tried setting the VisualEdgeMode property of your DrawingVisuals
to Aliased (or maybe setting RenderOptions.EdgeMode="Aliased" on your RenderTargetBitmap,
something like RenderOptions.SetEdgeMode(renderBitmap, EdgeMode.Aliased); ?
I am trying to develop a desktop application in which I need to save some data locally. There will be images and information related to images in xml. There can be 100’s of images and multiple xml files.
1. How can I save all files (images + xml file) into one DAT file (so to speak)?
2. Could it be possible to save files in different folders inside that DAT file? If yes, how?
3. If I decide to use Access dbf file instead of xml, can it be saved as part of dbf file?
Please advice. Thanks
Follow your goals, Means will follow you ---Gandhi---
For some reason I have to use the cumbersome Pack URI format to access an image file in my assembly. When I use a relative URI I get a System.InvalidOperationException on the following statement: Uri uri = new Uri(ResourcePath, UriKind.Relative);. It works fine when I use the following statement: Uri uri = new Uri("pack://application:,,,/" + ResourcePath);. Here ResourcePath is set to "Resource/Screenshot.png" and "Resource" is directly under my project in the Solution Explorer. Of course the Build Action of the .png file is set to "Resource" or even the Pack URI wouldn't work, which it does. What could be causing this kind of problem?
I looks like I'm doing exactly the same thing you are, but it's not working, so I must be missing something. Here "Resource" is a folder in my Solution Explorer project that contains the .png file. But the absolute path into my project is not being resolved. The Solution Explorer path relative to my project is: Resource/screenshot.png.
In reading the MSDN documentation, it seems to be saying I should preface the path with a slash. But when I do that, it resolves to an absolute path in the Windows file system that winds up in the Debug folder of my project, looking for the file at C:\...\bin\debug\Resource\screenshot.png. None of the MSDN documentation that I'm reading says that should happen!
Everything I'm reading says that absolute pack URI's should be fully exchangeable with relative pack URI's. But I can't get relative pack URI's working no matter what I try. Any ideas what's wrong?
Your "ResourcePath" contains a valid value for sure?
By this you mean what I've been specifying as Resource/screenshot.png? If so, then yes, it has to be valid, because specifying the absolute URI works. I have these lines in my code so I can easily switch back and forth between absolute and relative URIs:
Uri uri = new Uri("pack://application:,,,/" + ResourcePath);
Uri uri = new Uri(ResourcePath, UriKind.Relative);
Mark Salsbery wrote:
Also, I would try naming the folder something other than "Resource",
not that I know of any reason why "Resource" shouldn't work...
I tried renaming it to "Screenshots" with the same failure with relative URIs and success with absolute URI. I also tried with and without an initial slash in the relative path.
Mark Salsbery wrote:
Other than that, I'm not sure why it wouldn't be working.
Anyone else have any ideas? Relative URIs is something I've never been able to get working in my 70,000 line WPF app. I've got absolute URI's all over the place to get around the problem. I even defined a global string so I wouldn't have to repeat the "pack://application:,,,/" string in a bunch of different places. There must be some kind of Dev Studio project setting that is causing relative URIs to be interpreted incorrectly.
Thanks for your reply and hanging in there on this extremely puzzling failure of UriKind.Relative. I did as you said, adding an ImageFailed handler to the image. When I set image.Source to the BitmapImage however, The ImageFailed event did not occur. The image simply did not show up in the window containing the image.
What I want to do is set the window Width and Height based on the PixelWidth and PixelHeight of the BitmapImage (taking into consideration the window border width and window option height -- irrelevant details). But the effort to get PixelWidth and PixelHeight causes an exception, in the following code:
As you can see, I set a default width and height to 450x300, just so the window shows up at all, but it shows up empty. string error in the exception handler says this (slightly simplified so just so you get the idea that it is looking at a path in my source code rather than a path in my project assembly):
"Could not find a part of the path 'C:\\...\\bin\\Debug\\Images\\screenshot.png'."
I did exactly the same thing you did in your example. I put a .png file in a folder off the project called Images, made sure its BuildAction was Resource, then tried to look at the BitmapImage.PixelWidth (which I needed to size the window exactly that was to contain the image). I got an exception that reported that it "couldn't find part of the path", and it quoted a path something like, "C:\...\bin\Debug\Images\Airplane.png". Then when I set the image Source to the BitmapImage I got no exception and when I hovered over the image.Source code in the debugger, it showed a URI something like this:
I'm not sure what's happening on your end, but you
shouldn't be getting any paths like "C:\...\bin\Debug\Images\Airplane.png",
since that is NOT a pack uri for extracting a resource image.
As far as getting PixelWidth/PixelHeight, that could be tricky.
For example, with the following code:
myimage.ImageFailed += new EventHandler<ExceptionRoutedEventArgs>(myimage_ImageFailed);
Uri uri = new Uri("/Images/Airplane.png", UriKind.RelativeOrAbsolute);
BitmapImage bi = new BitmapImage();
bi.UriSource = uri;
myimage.Source = bi;
with a breakpoint on "myimage.Source = bi;", bi.PixelWidth/bi.PixelHeight
are 0, and also having the breakpoint there causes the image to not appear.
Put a breakpoint after "myimage.Source = bi;" (removing the
previous breakpoint!) and bi.PixelWidth/bi.PixelHeight are valid (but
is that just lucky timing?).
It appears the decoding is asynchronous, and I see no event for
Microsoft MVP - Visual C++
Last Visit: 31-Dec-99 18:00 Last Update: 3-Oct-23 21:57