Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6368419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:40:23+00:00 2026-05-25T00:40:23+00:00

I’m relatively new to C# and .Net, and this is my first WPF project,

  • 0

I’m relatively new to C# and .Net, and this is my first WPF project, so I’m hoping this is just a case of lack of familiarity and weak Google-Fu on my part.

I need to create a preview window for an HTML5 development tool. The pages will contain javascript, ogg vorbis and/or mpeg4 (m4a) audio, and png images.

The Frame control seems to work fine for viewing the file. I initially tried the WebBrowser control, but it seems to be based on IE7, which doesn’t support the functionality I need. Frame seems to use the installed IE9, which is what I need. The problem seems to be in loading the content.

I can get it to work if the page is hosted on an Apache-based web server, but that is definitely not the preferred solution. Professional web developers aren’t the target audience, so I feel it’s unreasonable to expect the users to be able to install and configure one. I’ve tried to implement a bare-bones server using HttpListener, but (a) it doesn’t seem to work any better than just setting the Frame Source=”C:/test_project_path/index.html” directly, and (b) I don’t want to create any problems if a user already has a web server running on their machine. I’ve had issues with “conflicts with existing registration” exceptions when trying to add the prefix — even though I have no other web server installed, let alone running, and I verified that nothing else is using the same port — which makes me hesitant to rely on it.

What I’d really like to be able to do is:

myFrame.Navigate("C:/test_project_path/index.html");

This almost works. I seem to get the graphical elements, but the javascript application crashes with a “Unable to get value of property: object is null or undefined” error. Since, as I said, it works when served from Apache, it seems that the issue is that not all of the javascript files are loading properly.

My questions:

Are there any settings that I’m missing? I get a security warning about active content, which I have to click through. I’d like to get rid of that, but it isn’t my main concern right now if it doesn’t directly relate to my current problem.

Is there some way to check whether the Frame control is doing all the necessary subrequests to load the page, and that they’re being fulfilled? Putting a watch on myFrame, I can only see the initial page (index.html). There doesn’t seem to be a way to tell if the various sub-elements are there other than what myFrame renders and the javascript errors I get.

Do I need to invoke the javascript files with InvokeScript(), or is that just for accessing functionality from a WPF control?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:40:23+00:00Added an answer on May 25, 2026 at 12:40 am

    Edit: A more general solution can be found here: http://forums.devshed.com/net-development-87/serving-images-using-httplistener-414552.html
    It seems to work for all the file types I’m dealing with.

    It seems the problem was in the way the server was encoding non-text files for the output stream. I was doing it this way, which is more or less how it’s done in most of the examples I found online:

    StreamReader streamReader = new StreamReader(requestUrl);
    byte[] buffer = Encoding.UTF8.GetBytes(streamReader.ReadToEnd());
    response.ContentLength64 = buffer.Length;
    response.OutputStream.Write(buffer, 0, buffer.Length);
    response.OutputStream.Close();
    

    This works fine for text files, such as html and javascript, but for images it seemed to be throwing in a bunch of extra junk, basically doubling the file size. The solution was to read in the image as an image, then save that to the output stream:

    Image image1 = Image.FromFile(requestUrl);
    image1.Save(response.OutputStream, System.Drawing.Imaging.ImageFormat.Png);
    response.OutputStream.Close();
    

    Obviously, you’d need to change the ImageFormat to handle whatever image types you want to serve. This works for PNGs, and I suspect the solution for sound files is similar, though I haven’t worked that out yet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I want use html5's new tag to play a wav file (currently only supported
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.