Stopwatch class not found in System::Diagnostics ?

I am using VC++ 2005. In several projects that I have created I have never had this problem but now that I created a DLL project (used the Win32 wizard), I am having this weird problem where the System::Diagnostics namespace shows up a few namespaces and classes, but not nearly all that belong there. For example, the CodeAnalysis namespace is shown, then ConditionalAttribute, DebuggableAttribute, Debugger, and so on until SymbolStore, which is the last namespace/class listed. No Stopwatch and many other namespaces and classes that should be there. What is wrong It must have something to do with the project settings but I don't even know where to look to find the missing namespaces and classes. Any idea Thanks.

Kamen




Answer this question

Stopwatch class not found in System::Diagnostics ?

  • philipsh

    How do I "reference an assembly" I tried #using <System.dll> but that must not be it...

    Kamen



  • blixt174963

    When you enable managed extension for your application a single reference is created for you behind the scenes to mscorlib.dll which is one of the most fundamental .NET assemblies. Within it are many of the most important types and where all of those classes you had access to are located.

    In general all managed apps or unmanaged ones that are using the CLR require the use of mscorelib and any classes defined in other assemblies need to be manually referenced.

    Does this make things a little more clear



  • stallion_alpa

    Not all types in a namespace are contained in the same assembly. Are you sure you've referenced all the assemblies that you need

  • Apollo13

    From the sounds of it you’ve already got your project setup to use the CLR, to add a reference right click on your project choose the References entry and enter its properties page, once there click the Add New Reference button. On the window that appears scroll down and double click on System to add a reference to it.

  • Crosscourt

    Yes sir, very clear now!

    Kamen



  • AdrianGodong

    Sounds like you're somehow referencing the .NET Compact Framework. I know the StopWatch class is not available there...


  • curtKauf

    HI!

    I have the same problem that Kamen had, but specifically with the Stopwatch class. This is wath appears on my form code:

    using System;

    using System.Diagnostics;

    using System.Collections.Generic;

    using System.ComponentModel;

    using System.Data;

    using System.Drawing;

    using System.Text;

    using System.Windows.Forms;

    I need to use the stopwatch class urgently for my designs but I just can't because of this problem. I'm using Visual Studio 2005 C#.

    Please help me with this problem. Thanks!.

    Jose Picon


  • Mike Lapierre

    Thank you very much Brendan and Peter, that resolved the problem. In my project settings, there were no references to anything at all. While it's understandable how that happened - the project was started as a Win32 DLL and then I added the /CLR option - I still don't understand why I could still use so many classes with no references in the project I'm very touchy about this project because I'm trying to do something quite complex and don't want to be bitten again by some obscure .Net-related problem.

    Kamen



  • Moridi

    Peter is correct, make sure you've got System.dll referenced as it is there that System.Diagnostics.StopWatch is defined.

  • Stopwatch class not found in System::Diagnostics ?