I have written a simple C# CGI executable to run under IIS7 using VS C# 2010 Express (.NET 4 framework). It takes HTTP POST data and builds a TCP Client request and sends the request to a running TCP server application running under the admin account. The application will respond back to the CGI executable and an HTTP response will be built and delivered back to the CGI client. This is running under Vista but will be moved to a Windows Server 2008.
Although I have set the usual CGI permissions etc. I am currently having system security /permission trouble when the CGI is invoked and the TcpClient call is executed:
...
Code:
try
{
server = new TcpClient("127.0.0.1", port);
}
catch (SocketException)
{
//...
return;
}
...
What needs to be done to make this work? The System.Security.Permissions.FileIOPermission settings seem to be corrupted but I don't know where to look for the problem. Security settings interacting at muiltiple levels gets to be confusing. How can I isolate and resolve this?
The following errors are returned:
Unhandled Exception: System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.ArgumentException: Illegal characters in path. at System.Security.Permissions.FileIOPermission.HasIl legalCharacters(String[] str) at System.Security.Permissions.FileIOPermission.AddPa thList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList) at System.Security.Permissions.FileIOPermission..ctor (FileIOPermissionAccess access, String path) at System.AppDomainSetup.VerifyDir(String dir, Boolean normalize) at System.AppDomainSetup.get_ConfigurationFile() at System.Configuration.ClientConfigPaths..ctor(Strin g exePath, Boolean includeUserConfig) at System.Configuration.ClientConfigPaths.GetPaths(St ring exePath, Boolean includeUserConfig) at System.Configuration.ClientConfigurationHost.GetSt reamName(String configPath) at System.Configuration.ClientConfigurationHost.get_I sAppConfigHttp() at System.Configuration.ClientConfigurationSystem..ct or() at System.Configuration.ConfigurationManager.EnsureCo nfigurationSystem() --- End of inner exception stack trace --- at System.Configuration.ConfigurationManager.EnsureCo nfigurationSystem() at System.Configuration.ConfigurationManager.PrepareC onfigSystem() at System.Configuration.ConfigurationManager.GetSecti on(String sectionName) at System.Configuration.PrivilegedConfigurationManage r.GetSection(String sectionName) at System.Diagnostics.DiagnosticsConfiguration.GetCon figSection() at System.Diagnostics.DiagnosticsConfiguration.Initia lize() at System.Diagnostics.DiagnosticsConfiguration.get_So urces() at System.Diagnostics.TraceSource.Initialize() at System.Net.Logging.InitializeLogging() at System.Net.Logging.get_On() at
System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port) at ConsoleApplication1.Program.tcp_client_request(Str ing op, String reg, String reg_value) at ConsoleApplication1.Program.handle_post_requests() at ConsoleApplication1.Program.Main(String[] args)
Thanks for any help.