Microsoft KB Archive/322086

= PRB: Application Configuration File on Web Server Is Not Accessible When You Run Executable File in Internet Explorer =

Article ID: 322086

Article Last Modified on 4/16/2007

-

APPLIES TO


 * Microsoft .NET Framework 1.1
 * Microsoft .NET Framework 1.0

-



This article was previously published under Q322086



SYMPTOMS
In Microsoft Internet Explorer, if you run an executable file (EXE) that is located on a Web server, the EXE file cannot read the information from the associated application configuration file (.exe.config), although the configuration file is also located on the Web server.



CAUSE
When you have ASP.NET installed on your computer, ASP.NET handles all HTTP requests for configuration files. By default, ASP.NET is configured not to permit access to configuration files. Therefore, your EXE file is not permitted to gain access to the corresponding application configuration file.

Note The default configuration settings for your computer are stored in the machine configuration file (Machine.config). Machine.config is located in the following folder:

\Microsoft.NET\Framework\v1.1.4322\Config



RESOLUTION
To resolve this problem, change your configuration settings so that your EXE file is permitted to gain access to the application configuration file. To do this, follow these steps:   In a text editor (such as Notepad), paste the following code:        Name the file Web.config, and then save it in the same folder as your EXE file.

Important If the Web.config file already exists, add only the  section to the existing Web.config file. In Internet Explorer, run your EXE file.</li> Notice that the settings from the application configuration file are also used. For example, if you run MyApp.exe (you can create MyApp.exe by following the steps in the &quot;More Information&quot; section of this article), the following text appears in Internet Explorer:

good day

</li></ol>

<div class="status_section">

STATUS
This behavior is by design.

<div class="moreinformation_section">

Steps to Reproduce the Behavior
<ol> Start Visual Studio .NET, and then use Visual Basic .NET or Visual C# .NET to create a new Console Application named MyApp .</li>  Add the following code to Sub Main:

Visual Basic .NET Sample Code System.Console.WriteLine(&quot;good &quot; + System.Configuration.ConfigurationSettings.AppSettings(&quot;good&quot;)) System.Console.ReadLine Visual C# .NET Sample Code System.Console.WriteLine(&quot;good &quot; + System.Configuration.ConfigurationSettings.AppSettings[&quot;good&quot;]); System.Console.ReadLine; </li> In Solution Explorer, right-click your application name, point to Add, and then click Add New Item.</li> Under Templates, click Application Configuration, and then click Open.</li>  Add the following application settings element in the   section: <appSettings> <add key=&quot;good&quot; value=&quot;day&quot;/> </appSettings> </li> On the Build menu, click Build Solution.</li> Copy the MyApp.exe file and the MyApp.exe.config file to the root folder of your Web Server.</li> Start Internet Explorer, and then paste the following address in the Address bar:

http://localhost/MyApp.exe

</li> Click Go. In Internet Explorer, only the following text appears:

good

Notice that day does not appear.</li></ol>

<div class="references_section">