1
Answer

Launched Application App.config

Johnny

Johnny

15y
3.9k
1
Hi there fellows!

I have an host application that launches another application (client) in runtime (process.start) and I need it to use hosts app.config, to use the system.diagnostics for logging configuration!

The problem is that when the client is launched independently, using it's own app.config file, it works fine, but when using the hosts, it doesn't! doesn't log anything at all...

Any clue on this?

Thanks a lot!
johnny
Answers (1)
0
Ken Barrett

Ken Barrett

NA 173 0 15y
Looks as if I figured it out.  It may not be the most elegant solution, but it seems to work.. and I understand it.

By number of entries  I meant that the number of entries that are in the guest book are variable. This depends on how many people have signed it.  So the number of entries that are shown on the view guest book page depends on how many people have signed the guest book.

The way I solved this was first to include a html span on the web page. As in :
<!-- start guest book entries -->
<span id="GBentries" runat=server></span>


Then I used a data reader (I like data readers because I'm old fashioned) to load only the date, name, and comments out of the data table. There's a lot more data in there, but I only want to display these items.  As in :
  private int getGBentries() {
    int rows = 0 ;
    string cmd = "SELECT Date, Name, Comments FROM dbo.Guest" ;
    using (SqlConnection gconn = new SqlConnection(dbConn))
    {
      try {
        gconn.Open() ;
        SqlCommand Scmd = new SqlCommand(cmd, gconn);
        SqlDataReader dr = Scmd.ExecuteReader() ;
        while(dr.Read()) {
          GuestEntry ge = new GuestEntry((DateTime)dr["Date"],
                            (string)dr["Name"],(string)dr["Comments"]) ;
          entries.Push(ge) ; // build a stack to be used later
          rows++ ;
        }
        dr.Close() ;
        gconn.Close() ;
        return(rows) ;
      } catch {
        return(0) ;
      }
    }
  }


As each item was read in a string object was appended with a new html table to hold that particular entry.  As in :
  private void buildEntries() {
    foreach (GuestEntry ge in entries) {
      guestOut +=
        "<table width=800 cellpadding=8>\n" +
        "  <tr><td colspan=2><hr /></td></tr>\n" +
        "  <tr>\n" +
        "    <td width=200>Date</td>\n" +
        "    <td width=600>" + ge.getCommentDate().Date + "</td>\n" +
        "  </tr>\n" +
        "  <tr>\n" +
        "    <td width=200>Name</td>\n" +
        "    <td width=600>" + ge.getName() + "</td>\n" +
        "  </tr>\n" +
        "  <tr>\n" +
        "    <td width=200>Comments</td>\n" +
        "    <td width=600>" + ge.getComment() + "</td>\n" +
        "  </tr>\n" +
        "</table>\n" ;
    }
  }


Then the string was written out to the span id on the web page. As in :
  protected void Page_Load(object sender, EventArgs e) {
    getGBentries() ;
    buildEntries() ;
    GBentries.InnerHtml = guestOut ;
  }

0
Roei Bar

Roei Bar

NA 7.8k 0 15y
by saying number of entries, do you want the number of entries in the Guestbook or the number of entries to that page?

the number of entries in the guestbook is easy, use databindNavigator it will give you all the data you return for you to manipulate and also you can know how many entries or more truly to say how many rows you have...

for number of entries to page you need  a counter control that you can download all over