Guide: Setting Render-in-Process during Printing
Estimated reading time: 2 minutes
Occasionally the requirement to run the application with asp.net “impersonation” may arise, and in this case the IIS7 worker process starts a thread which runs under the credentials of the impersonated user. This is similar too, but slightly different than, logging onto the Windows workstation with the same credentials. In particular, when the worker process is running as the “Network Service” identity (as per default IIS7 configuration), the impersonation thread is not allowed to create new processes with the same authority as a logged-on user with its credentials.
This can create an issue because DataGate client performs Windows printing functions by generating a “meta-file” containing Windows-specific generic printing information. The renderer uses this meta-file to perform the actual printing. By default the client starts the renderer as a separate process. This process must load the print file controls assembly in order to print the contents of the print file’s fields. In the scenario described in the previous paragraph however, the renderer fails to load the controls assembly: The load fails because of a requirement for that assembly to access the WinForms subsystem of .NET; the Network Service identity of the parent process is inherited by the renderer’s process, and Window2008R2 does not allow that identity to access UI facilities.
To resolve this issue, DataGate can be instructed to Render-in-Proc, rather than as a seperate process. Doing so involves adding the following code to the .config file for the application, website, or machine (application.config, web.config, or machine.config) where Render-in-Proc is to be used.
<configuration> <configSections> <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > <section name="ASNA.DataGate.Client.Properties.PrintingProps" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> </sectionGroup> </configSections> <applicationSettings> <ASNA.DataGate.Client.Properties.PrintingProps> <setting name="RenderInProc" serializeAs="String"> <value>True</value> </setting> </ASNA.DataGate.Client.Properties.PrintingProps> </applicationSettings> </configuration>
To disable render-in-process, either remove the above, or change the content of the <setting name=”RenderInProc”> element to “<value>False</value>”.
See Also
AdgDataSet Class
Database File Records and AdgDataSet
Efficient File Access
FileAdapter Class
Reading and Writing to Database Files
Using the FileAdapter Class