WinForm UserControls in Internet Explorer

Update:  Its fixed!  Thank you Marc.

I was hoping to post about the cool demo I've been building with a WinForm UserControl in Internet Explorer, but I apparently need some help finishing it up.  You can view my page and control and the error here.  My control downloads and initializes/displays correctly, but its supposed to call a webservice to get the data.  This worked when running locally, even with remote webservice, but now that I've deployed it to production it fails when trying to get the data.  The error message mentions an IExplore.exe.config file, but searching on this reveals few references and no real help, and I fail to see how such a file on the server would accomplish anything since security in asp.net will stop my browser from being able to retrieve config files.

Here's majority of the error -- anyone able to help me out?

System.Configuration.ConfigurationException: Error loading XML file http://www.wilsondotnet.com/IEXPLORE.EXE.config This is an unexpected token. The expected token is 'DOCTYPE'. Line 2, position 3. (http://www.wilsondotnet.com/IEXPLORE.EXE.config)
at System.Configuration.ConfigurationSettings.GetConfig(String sectionName)
at System.Web.Services.Configuration.WebServicesConfiguration.get_Current()
at System.Web.Services.Protocols.SoapClientType..ctor(Type type)
at System.Web.Services.Protocols.SoapHttpClientProtocol..ctor()
at Wilson.DotNet.WinForms.Services.TipsWS..ctor()
at Wilson.DotNet.WinForms.TipsControl.TipsControl_Load(Object sender, EventArgs e)
at System.Windows.Forms.UserControl.OnLoad(EventArgs e)

11 Comments

  • >The error message mentions an IExplore.exe.config file, but searching on this reveals few references and no real help, and I fail to see how such a file on the server would accomplish anything since security in asp.net will stop my browser from being able to retrieve config files.





    Well, I guess that is the problem then :) - Something that you use inside the assembly calls Ieexplorer.exe and as it run through the server it tries to find a ieexplorer.exe.config at the same origin it got the assembly from which is your server. Since your server is configured to disallow *.config to be send back, an error page is produced and send back instead. The doctype is unexpected as it should not be in an *.config file (or any XML...). Try the following: temporarily allow *.config in that sub dir and see how that goes. Alternatively you could allow *.config and disallow web.config.

  • Thanks to all the comments so far. Here's my analysis of it to this point. Please continue to give me any advice you can think of. Even if it turns out to not be the problem, it is still valuable in helping me sort through it!





    Dave: The control loads fine, but the data that should show up in the control is never loaded since this is the call that the control makes back to the server. I removed the DocType tag as a test and it still gave the same error, so I think this is occurring due to the lack of the IExplore.exe.config file. Other than the mention of DocType for whatever reason, the rest of the error is definitely related to the calling of my webservice, not the loading of the page since that is already done.





    Marc: Its not that I'm using something that calls IExplore.exe, its more the other way around: IExplore.exe is calling my web service. Now, what to do about it? First, I need to know what to put in this config file, and the only mentions of it on the web seem to indicate it should state which version of the framework is supported. Maybe this is a clue that somehow I need to include this in the control itself, but I don't know if that is possible. Maybe if I built it with .Net v1.0 instead of v1.1 it wouldn't be a problem, but I specifically chose v1.1 since I've read in multiple places that v1.1 solves some security issues with WinForms in the browser. Anyhow, maybe I should try it v1.0 when I get a chance to see if that helps. Finally, even if I knew what to put in this file, changing the default security to serve up config files would be totally unacceptable, even if that is the only solution, since that would reveal all of my private settings in web.config! Yikes.





    ChadB: Wow -- that's a lot. Maybe as I dig through it I will find what I need. Can you by chance shed any more light on this stuff?


  • chadb's article taught me some new stuff, I didn't know much about that IEExec stuff work, very helpfull!! - From seeing the win form I was under the impression that you were using the IE control or even MSHTML to display stuff in the win form, maybe that got me on the wrong track.





    You don't actually have to have a ieexplorer.exe.config file, the problem seems to be that ASP.NET WP returns an unexpected page instead of either a) a real config file or b) a 404. Ieexec can handle a 404 which works just fine. But if you (ASP.NET...) return a real page, it thinks it gets the config file and tries to read it which in turn produces the exception.





    To my knowledge you _have_ to use v1.1 or else the security stuff wouldn't work, so you are right to stick with v1.1.





    And don't worry about security, you can still block your web.config and you can set it up just for that single directory to allow *.config files. This is from one of our projects (hope this gets through...):





    <remove verb="*" path="*.config" />


    <add verb="*" path="web.config" type="System.Web.HttpForbiddenHandler"/>





    Machine.config disallows _all_ config files and I changed it so that just web.config files are forbidden.





    So, if you simply add this to your web.config in that single sub dir, it wouldn't surprise me if it works!! - Anyway, it's worth a try :)

  • Thanks Marc! That seems to have fixed it, although anyone that was previously testing it may possibly need to clear cached files and/or close your browser before the changes are picked up successfully. I also ended up creating a skeleton IExplore.exe.config file that now does get served to the browser.

  • Yep. Since I never ache anything, this fixed it for me perfectly. Now, let me understand this... .NET mean DLL hell no longer exists? ROFL. Wow, this gets archived for me.

  • I think in this case its more like security hell, and while its certainly a pain I think that's very much acceptable. Note that I would not have had this problem if I was using a more traditional GUI control, but mine is different since it calls back over the web-service. Overall, this was a much more pleasant experience than trying to get ActiveX controls working in the browser, so I would call it a huge improvement. Although there is that huge .NET redistributable that has to be installed on all the clients. :) By the way, the reason I'm using a web-service to retrieve the data is that the default sandbox security for WinForm controls in the browser does not allow real database connections! That stunned me the first time I saw it, but after thinking more I think its the proper security call.

  • I am having trouble getting my WinForm to show up on non-localhost machines.



    I get the control outline and then the control icon in the top left corner.



    Any ideas - it works great on my localhost machine and I can see your Windows Form.



    Thanks

  • Hi Darcy:



    You need to be have .NET v1.1 on client for security to be correct by default. I'm not sure, but it may be necessary to compile your WinForm control dll against v1.1 and have your ASP.NET site running v1.1 also.



    The control dll needs to be on the server in a folder that's accessible (not the bin). You need to make sure you are not referencing any system colors, but you've probably already done that if it works locally. Many things, like database access and file IO are still not allowed by default, but you should get an error in most cases. Some things also require having an IExplore.exe.config, like calling back with a webservice, which is a pain to setup and was the butt of my original problem that was posted here.



    I hope one of these hints helps, if not give me some more details about what yours is doing and maybe we can find something else.



    Later, Paul Wilson

  • You may want to take a look at MS knowledgebase article 814668.

  • How do i set my internet explorer to allow for flash aniamtion playing well?

  • ? Flash ? Never heard of it. :) Seriously though, I don't know anything about Flash.

Comments have been disabled for this content.