Trace not working in C#

T

tshad

I have been working in VB.net and have never had a problem with trace.warn
or trace.write.

I have a test program in C# that is giving me an error:

******************************************************************************
Compiler Error Message: CS0246: The type or namespace name 'trace' could
not be found (are you missing a using directive or an assembly reference?)

Source Error:

Line 62: string FILE_PATH = @"\\" +txtMachine.Text +
@"\C$\windows\System32\LogFiles\";
Line 63:
Line 64: trace.write("FILE_PATH = ");
******************************************************************************

The beginning of my page is:

*****************************************************************************
<%@ Page Language="C#" trace="true" AutoEventWireup="false" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Diagnostics" %>

<script language="c#" runat="server">
*********************************************************************************

The error is in a routine:
*************************************************************************
private void PopulateSiteBox()
{
drpSiteBox.Items.Clear();
string FILE_PATH = @"\\" +txtMachine.Text +
@"\C$\windows\System32\LogFiles\";

trace.write("FILE_PATH = ");

DirectoryInfo di = new DirectoryInfo(FILE_PATH);
foreach(FileSystemInfo fsi in di.GetFileSystemInfos())
{
if(fsi.Name.StartsWith("W3"))
drpSiteBox.Items.Add(fsi.Name);
}
}

************************************************************************

Why doesn't is know about it?

Thanks,

Tom.
 
B

bruce barker

C# is case sensitive, try:

Trace.Write()

-- bruce (sqlwork.com)


| I have been working in VB.net and have never had a problem with trace.warn
| or trace.write.
|
| I have a test program in C# that is giving me an error:
|
|
****************************************************************************
**
| Compiler Error Message: CS0246: The type or namespace name 'trace' could
| not be found (are you missing a using directive or an assembly reference?)
|
| Source Error:
|
| Line 62: string FILE_PATH = @"\\" +txtMachine.Text +
| @"\C$\windows\System32\LogFiles\";
| Line 63:
| Line 64: trace.write("FILE_PATH = ");
|
****************************************************************************
**
|
| The beginning of my page is:
|
|
****************************************************************************
*
| <%@ Page Language="C#" trace="true" AutoEventWireup="false" %>
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
| <%@ Import Namespace="System" %>
| <%@ Import Namespace="System.IO" %>
| <%@ Import Namespace="System.Data" %>
| <%@ Import Namespace="System.Diagnostics" %>
|
| <script language="c#" runat="server">
|
****************************************************************************
*****
|
| The error is in a routine:
| *************************************************************************
| private void PopulateSiteBox()
| {
| drpSiteBox.Items.Clear();
| string FILE_PATH = @"\\" +txtMachine.Text +
| @"\C$\windows\System32\LogFiles\";
|
| trace.write("FILE_PATH = ");
|
| DirectoryInfo di = new DirectoryInfo(FILE_PATH);
| foreach(FileSystemInfo fsi in di.GetFileSystemInfos())
| {
| if(fsi.Name.StartsWith("W3"))
| drpSiteBox.Items.Add(fsi.Name);
| }
| }
|
| ************************************************************************
|
| Why doesn't is know about it?
|
| Thanks,
|
| Tom.
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top