Can't use NTrace in Web Application Project

Feb 22, 2009 at 5:02 AM
Hi,

I am following the "Adding NTrace Support to Existing Projects" chapter in the "Using ETW Tracing in your Application.pdf" documentation to setup NTrace in my ASP.NET Web Application Project.  I've got 1 warning & 1 error.

1. The warning message shown below:

   Controllers\HomeController.cs(22,13): warning CS0122: 'System.Web.EtwTrace' is inaccessible due to its protection level

2. The error message shown below:

   C:\Program Files\MSBuild\NTrace\v1.0\NTrace.CSharp.WebApplication.targets(133,5): error MSB3021: Unable to copy file "obj\Debug\MvcApplication1.pdb" to "obj\Trace\MvcApplication1.pdb". Could not find file 'obj\Debug\MvcApplication1.pdb'.

---

Does anyone know how to fix this problem?
Coordinator
May 2, 2009 at 7:21 PM
I'm terribly sorry; I hadn't received a notification of your comment, and just saw it. Are you still encountering this issue?
May 4, 2009 at 2:13 PM
Edited May 4, 2009 at 2:14 PM
Yes.  This problem still exist.

Also, I have a Windows Service application that can't embed NTrace into it either.
Coordinator
May 4, 2009 at 2:38 PM
I'm afraid I was not able to reproduce your exact issue, but I did find that the instructions for adding NTrace into an existing project are missing two steps:
3) Add a trace helper: This is merely a static member to hold a reference to the NTrace provider at runtime. The fully-qualified name (namespace.class name.member name) need to match the <EtwProviderVariable> property in the project. An example is below:

// TraceHelper.cs
namespace

 

WebApplication1
{
  internal class TraceHelper
  {
    /// <summary>
    /// The object used for all NTrace tracing
    /// </summary>
    internal static readonly NTrace.ClassicProvider provider;
  }
}

4) Add a reference to NTrace.dll (located in %ProgramFiles%\NTrace)

If you attach a copy of your .csproj file to this thread, I may be able to determine what the issue is.

May 5, 2009 at 2:00 AM
Are you using Visual Studio 2008 SP1 too?
Coordinator
May 5, 2009 at 2:53 AM
Yes, that is correct: I am using Visual Studio Professional 2008 SP1.
Sep 17, 2009 at 4:39 PM

Has anyone figured out how to get this working in a Web Application project?  I am having the same issue as doggy8088.

Coordinator
Sep 17, 2009 at 9:08 PM

I have been able to create/run instrumented Web projects using NTrace 1.0 and 1.1. It should be noted that the instructions for adding NTrace need to be updated to use 1.1: rather than replacing the Microsoft.CSharp.Targets, add a reference to the NTrace 1.1 targets:

  ...
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <Import Project="$(MSBuildExtensionsPath)\NTrace\v1.1\NTrace.CSharp.targets" />
  <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
  ...

Can you provide an example of your project's .csproj file?

-Andy

Sep 18, 2009 at 3:46 PM

I get the following errors when using the imports as you describe:

Warning               1              There is a circular reference involving the import of file "C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.CSharp.targets". This file may have been imported more than once, or you may have attempted to import the main project file. All except the first instance of this file will be ignored.                MvcApplication3

Warning               2              Unable to copy file "obj\Debug\MvcApplication3.dll" to "obj\Trace\MvcApplication3.dll". Could not find file 'obj\Debug\MvcApplication3.dll'.             MvcApplication3

Warning               3              Unable to copy file "obj\Debug\MvcApplication3.pdb" to "obj\Trace\MvcApplication3.pdb". Could not find file 'obj\Debug\MvcApplication3.pdb'. MvcApplication3

Attached is the project file.  It's just the basic MVC project from File…New…Project.

From: ahopper [mailto:notifications@codeplex.com]
Sent: Thursday, September 17, 2009 4:09 PM
To: Scott LaFave
Subject: Re: Can't use NTrace in Web Application Project [NTrace:48128]

From: ahopper

I have been able to create/run instrumented Web projects using NTrace 1.0 and 1.1. It should be noted that the instructions for adding NTrace need to be updated to use 1.1: rather than replacing the Microsoft.CSharp.Targets, add a reference to the NTrace 1.1 targets:

  ...
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <Import Project="$(MSBuildExtensionsPath)\NTrace\v1.1\NTrace.CSharp.targets" />
  <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
  ...

Can you provide an example of your project's .csproj file?

-Andy

Read the full discussion online.

To add a post to this discussion, reply to this email (NTrace@discussions.codeplex.com)

To start a new discussion for this project, email NTrace@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Coordinator
Sep 20, 2009 at 1:40 AM

Hi, Darth! I'm afraid nothing was attached - I'm guessing CodePlex filters that stuff out. Can you paste it inline or send it directly to me? You can reach me at ahopper@Wintellect.com.