Unofficial Content
  • This documentation is valid for:

Web Model

SQL server connection error during build

Apparently, there is no way to solve it; we suggest trying SQL server's suggestions and searching this issue online.

Copyright (C) Microsoft Corporation. All rights reserved.

"C:\Models\Knowledge Base Invoice\CSharpModel\web\bin\reor.exe" -nogui -noverifydatabaseschema


Internal error: Function call failed (A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server))
Internal error: Function call failed (A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server))
The reorganization process was not successfully completed.
Reorganization Failed

 

Can GENEXUS provide us with the solution to the above?

Model Configuration

        1.        Create an environment by going to the Preferences tab located in the Knowledge Base navigator, right-click on the Kb name, "New Environment." (By default, GeneXus creates an environment depending on the information given when creating the Knowledge Base.)

  §         Language = .NET
§         User Interface = Web
 

2.        Set model properties: Preferences/ .NET Environment

§         Target Path
  §         User Interface
  §         Language: C#
        §         Datasource: SQL SERVER | DB2 | ORACLE | POSTGRESQL | DB2 FOR ISERIES | MYSQL | INFORMIX
  §         Startup Object: None (by default)

3.        Set up DBMS options:

         §      Access technology to set: ADO.NET | JDBC | RUBY | iSeries Native

   §      Database name: <Database name> 
 
  §      Server name: <Server name or IP>

   §      Server TCP/IP Port:,<Port>
   §      Use trusted connection: No 
   §  User ID: <User>
  
§  User password: <Password> 

 4.       Set execution properties: Preferences / .NetEnvironment / Generator

    §        Compiler flags
 §        Compiler directory
    §       Reorganize server tables

  1.  

              5.       Run database creation (if the database does not exist, it will be created)

§  Build / Create Database

          6.    Generate, specify and compile programs:
     
                 §  Build / Build All / Rebuild All - in the "Build" Tab

                 7.    In the GeneXus "Build" tab you can choose either to run the startup object (developer menu by default) or any object whose "Main program" property is set to True. 

On compiling Webxxx, the Webxxx.dll (IL code) assembly is generated under the bin directory, and an entry may be added in web.config depending on the property HttpHandlerFactory.

The compilation output is sent to the Runout.log file.

         Hwebxxx.aspx is called at runtime.

Notes:

  • If trusted connection is set (step 3) you must also set ASP.NET rights. 
  • If ODBC access is used, you must set the Access technology in the DBMS Options to ODBC (Step 3) and Model Property Access Method to ODBC as well. To connect through an ODBC data source, it must belong to the system.
  • After compiling, GeneXus will create a virtual directory with the name specified in the local IIS, pointing to the < KB physical directory >\<target Path>\web.
  • When executing from an internal network directory, you must take into account the .NET permissions settings and Web server rights to execute an application for steps 5 and 7.

.NET Generator Properties

Web Server

Indicates the Web Server that will be used at runtime.   

Values

- Internet Information Server
- ASP.NET Development Web Server //WebDev
- WebDev.WebServer2

 
Default Value = It depends on the Web Server installed. If IIS or ASP.NET are installed, they are the default value, respectively. Otherwise, if no Web Server is installed, the default value is WEDdev.webserver2, which is installed with GeneXus.  
 

Object Generation 

After having specified an object, when generating it, the generator creates the following for each object: 
                              -       A file with the source code in C# language (.cs),
                              -       A file with the same name as the object and with '.rsp' extension. This file contains the information required to compile it (sources included, references, etc.). 
                              -    If it is main, it also creates a bld<object name>.cs file that executes the assembly of the object and the related ones (called from it). The other main objects are not included within the related ones since they are assembled compiling them specifically.  
                              -    If a reference is made to SDTs, collections or Business Components, a type_<sdt_name>.cs file is created with the definition of the structured type referenced.  
                              -    The gxcommon.rsp file is also created. Its objective is to create an assembly (with the same name) that includes the objects common to all the assemblies (SDTs, collections). 

Compilation

The code is compiled when Build is selected, and a .dll is generated with the common .NET code (IL). This is supervised, at runtime, by an interpreter (CLR) that allows executing it, converting it into a PC code. 
The log with the compilation result is displayed on the screen and stored in the RunOut.log file.
The Web.config file or the header object (depending on the config httphandler section property) contains the information on the web application configuration. There, each .dll is associated with a virtual page with ASPX extension. There is no physical .aspx file. The Web.config are sorted by priority in ascending order in the directory tree. 
Only with the Aspx value of this property, a physical file is generated for each object. 
The Web.Config file is generated from GXCFG.Web, which has an entry for each object and is the UpdateConfigWeb that enters the information to the Web.Config once the compilation is finished.  
Like the other generators, .Net is supported by a set of standard programs. These programs have StrongName which means that they are identifiable with a unique name in the .NET universe. Generated programs also have the possibility of setting up a strong name (but reorganization assemblies don’t). This is useful to do automatic deployment in Global Assembly Cache (GAC).

Advanced

Trace generation

To enable application trace generation (log file), you must set the Log level model property. This property adds two settings in the web.config file after the compilation. 

 1. Enables trace setting with the “threshold” tag

             <log4net threshold="<Value>">

  2. Enables the log file 

           <system.web>
               <trace enabled="true" />

In step 1, if <Value> is different from OFF,  log messages are generated, but they are sent to the ASP.NET trace and accessing the log file is not possible. Step 2 is performed with this objective.  

By default, the Web models have ASPNetTraceAppender as “root appender,” this means that it does not generate a file as a log file, but that it sends logging messages to the ASP.NET trace. Therefore, the above settings must exist for generating the file.
After generating a logging file from Web applications, you may see it by accessing the following URL: http://servername/dirvirtual/Trace.axd

When a remote Web application is run, including the localOnly ="false" option is necessary to view the trace from client PCs.
Otherwise, the trace will only be viewed from the server itself. For viewing the trace from client PCs, the following input must be introduced:
 <system.web>
    <trace localOnly="false" enabled="true" />

Notes:
- Log file generation may degrade application performance; this is why we recommend having it switched off in production.
- For <log4net threshold="OFF">, the log file is not generated, and none of the settings below (trace and root) are taken into consideration. In this case, log messages are simply not generated from xClasses.dll.

- From web applications, it is possible to generate a log file
- For more information about log4net, go to the following URL: http://log4net.sourceforge.net/<o:p> </o:p>

Configuration files

When working with .NET applications, we have configuration files where certain application properties are defined, such as the information for the connection to the database or the settings of a “log” file.

web.config

It is created when web applications are generated and is used when we run applications under Internet Information Server. 
It contains the settings of the application server's location, the database connection, and the log file generation, among others.  
It is located under the “csharp” model directory and its structure is similar to the following:  

<configuration>
  <appSettings>
    <add key="AppMainNamespace" value="GeneXus.Programs" />
    <add key="DataStore1" value="Default" />
    <add key="DataStore-Count" value="1" />
    <add key="Connection-Default-DBMS" value="sqlserver" />
                     ….
  </appSettings>

<log4net threshold="OFF">
         <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
         <file value="client.log" />

            ....
     
          </layout>
          </appender>
          <appender name="ASPNetTraceAppender" type="log4net.Appender.ASPNetTraceAppender">
          ......

           </layout>
           </appender>
           <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
                .....

           </layout>
           </appender>
           <root>
                   <level value="DEBUG" />
                   <appender-ref ref="RollingFile" />
           </root>
  </log4net>
 
<system.web>
       <trace enabled="false" />
       <httpHandlers>
                <add verb="*" path="*.aspx" type="GeneXus.HttpHandlerFactory.HandlerFactory,gxclasses" />
       </httpHandlers>
  </system.web>
</configuration>

The SystemWeb section is not rewritten by the generator. The Appsetting section is written by the generator after each compilation (model properties and generator settings are stored there). Note: This web.config is also used in distributed applications when the application Server runs under IIS. For further information, please refer to Distributed applications.

DataBase connection

The database connection information remains stored in the web.config file with the following format:  
  <appSettings>
    <add key="Connection-Default-DataSource" value="mydatasource" />
    <add key="Connection-Default-User" value="Elj20MqY44RPdvT8FEpDD0==" />
 
     

These tags are not framework proprietors; they are defined by the generator. In some cases, their contents do require a standard format defined by the platform. E.g., the database connection string in ADO.NET models with SqlServer may be:  

<add key="Connection-Default-Opts" value=";Integrated Security =No; Max Pool Size = 50; Min Pool Size=10" />

Identity impersonate

This allows web objects to run with the user that IIS transfers to the .Net platform. Otherwise, the processes run with the “machine” account (ASP.NET user).
It is specified within the System.Web section with the following tag:

<identity impersonate="true" />
 

Considerations:

        -          It is necessary if you want to use a trusted connection for the connection to the database (SQL Server); otherwise, it executes with ASPNET user.
-          PDF Reports: When identity impersonate="true," the user executing in the IIS page must have written rights over "C:\Documents and Settings\<webserver name>\<ASPNET\Local Settings\Temp" with IIS 5 or higher. With IIS 6.0 or higher (Windows 2003) rights must be granted over the directory C:\Windows\Temp\...\iTextdotNET. (but it is configurable).
Otherwise, the following error occurs:  Access to the path "C:\DOCUME~1\ARMIN-NB\ASPNET\LOCALS~1\Temp\e8ebd99f-17de-4447-83f8-35769f67bd23\iTextdotNET”<o:p> </o:p>

SessionState  

To implement sessions management (Websession data type) the generator uses the HttpSessionState provided by the framework. 
There are three ways to store the session state:

         1 – Inproc, which uses aspnet_wp.exe.
         2 - Stateserver used when there is more than one server.  
        3 – Sqlserver, which uses SQL Server tables instead of the web Server memory to store the information saved in the sessions.   

1-Inproc is the default mechanism implemented by the generator. When aspnet is recycled, session variables get lost. 
2-StateServer. The websession can be stored within the memory space of a process called aspnet_state.exe. 
This is useful in prototyping to maintain the websession, since after recycling aspnet_wp or compiling the objects and uploading them again, the websession is lost.
To implement it, you must first upload the <st1:place w&#58;st="on"><st1:placename w&#58;st="on">ASP.NET</st1:placename> <st1:placetype w&#58;st="on">State</st1:placetype></st1:place> Service (aspnet_state.exe) in the PC that will maintain the session. Then, you must add the following line in web.config:

  <system.web>
        <sessionState 
            mode="StateServer" 
            stateConnectionString="tcpip=name_pc:42424" />
             ....
            
....
  </system.web>

The stateConnectionString attribute contains the IP and port of the PC used to maintain the session. The default port is 42424.
3-Sqlserver. For this, you should:

3.a – Execute <Framework_Path>\aspnet_regsql.exe (or InstallSqlState.sql) for SQLServer session support.

3.b - Change web.config with the connection string  
   <system.web> 
        <sessionState mode="SQLServer" 
                      sqlConnectionString=" Integrated Security=SSPI;data source=dataserver;" 

For example, to store the session in a SQL server table, without Integrated security: 

3a - <Framework_Path>\aspnet_regsql.exe -S  SERVERNAME  -U  USER  -P  PASSWORD  -ssadd -sstype p 

The ASPState Database would be created. 

3b-  Modify Web.config file

<sessionState allowCustomSqlDatabase="true" mode="SQLServer" stateNetworkTimeout="20" sqlConnectionString="Data Source=SERVERNAME;Initial Catalog=ASPState;Integrated Security=False;User ID=USER;Password=PASSWORD" cookieless="false" timeout="20" />

Besides, you can set how long the session variables last. They expire by default; websession variables lose their value after a 20-minute timeout.  

This timeout can be set from:
        <sessionState mode="InProc"
                      cookieless="false"
                      timeout="20"/>

For more information, please refer to http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconsessionstate.asp
In w2003 Server, you can set the timeout by virtual directory. For this, in the virtual directory properties, you must set the value from:  Virtualdirectory\Configuration\options\Enabled Session State

Http Execution Timeout

There is a way of setting up the requests timeout in .Net applications (both in Web applications and in 3-tier applications hosted in the IIS).   
In Web applications, if a page request takes more than 90 seconds, a Request Timeout message will be sent to the browser.   
To avoid timeouts, you must create the following in the System.Web session of the web.config file:

<httpRuntime  executionTimeout="<secs>"/>

Where <secs> is the number of seconds you want to wait; e.g.: 3600.

For more information, please refer to the HttpRuntime section:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/gngrfhttpruntimesection.asp

 

Http MaxRequest Length

 There is a way of determining the maximum value of upload file size: 

              <httpRuntime  maxRequestLength="<size>"/> 

Where <size> is the number of bytes; e.g.: 20120. 

Generate log file – Rolling file

It is possible to set up a Web model so that it will also generate a text file by adding the following to the web.config file:

1.<appender  name="RollingFile" type="log4net.Appender.RollingFileAppender">
 
            <file  value="C:/<directorio del modelo>/web/log/client.log"/>
            <appendToFile  value="true"/>
            <maximumFileSize  value="9000KB"/>
            <maxSizeRollBackups  value="4"/>
            <layout  type="log4net.Layout.PatternLayout">
                        <conversionPattern  value="%d{HH:mm:ss,fff} %t %-5p                  %c{1} %x - %m%n"/>
            </layout>
</appender>

 

Please note that slashes “/” must be used for specifying an application directory.

 

    2. The <appender-ref  ref="RollingFile"/> input must also be included.

Input inside Tag root, for instance:
<root>
                <level  value="DEBUG"/>
                <appender-ref  ref="RollingFile"/>
                <appender-ref ref="ASPNetTraceAppender" />
</root>

It is important to differentiate “appenders” that are working as “root”, because these appenders are going to be considered by log4net when printing logging messages. It will send log messages to all appenders inside the “root” tag. 

In the previous case, since the "RollingFile" and “ASPNetTraceAppender" values are not set, the client.log file will be generated in the web/logging directory, below the model directory and access to the trace will also be possible through the following URL: http://servername/dirvirtual/Trace.axd

In this case, there is only a single appender:    
  <root>
                <level value="DEBUG" />
                <appender-ref ref="ASPNetTraceAppender" />
  </root>

Therefore, the client.log file will not be generated. It will only be possible to access the trace through the following URL: http://servername/dirvirtual/Trace.axd
If in a Web application web.config file the following is set:

  <log4net threshold="ALL"> 

and in the Tag root:
  <root>
                <level value="DEBUG" />
                <appender-ref ref=" RollingFile" />
  </root>

The following settings will not be taken into consideration:

  <trace enabled="true" /> 
  <trace localOnly="false" enabled="false" />

because these settings are only valid for the following appender:

   <appender-ref ref="ASPNetTraceAppender" />

For information about Deployment, please refer here

 

Last update: April 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant