type ProcessThread has no constructors defined

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MegaGreg

    #1

    type ProcessThread has no constructors defined

    I'm trying to inherit from System.Diagnost ics.ProcessThre ad but I keep
    getting the same error no matter what I try:The namespace 'CSRSystem'
    already contains a definition for 'Program'

    None of these pieces of code work:

    using System.Diagnost ics;
    namespace CSRSystem {
    class Program : ProcessThread{
    }
    }

    using System.Diagnost ics;
    namespace CSRSystem {
    class Program : ProcessThread{
    Program() { }
    }
    }

    using System.Diagnost ics;
    namespace CSRSystem {
    class Program : ProcessThread{
    Program() : base() { }
    }
    }

    I can't understand why the first one doesn't work. It's a public class,
    there's nothing in the documentation about not being allowed to inherit
    from it. I'm trying to get at the protected events member of this
    class, hoping it will give me what I'm looking for.

    Maybe there's a better solution to my problem. I'm trying to respond to
    a button click. The problem is that the button click is happening in
    another program that I didn't write, and don't have the source code
    for. Any solutions for the inheritance problem or the button click
    problem on a whole?

  • Jon Skeet [C# MVP]

    #2
    Re: type ProcessThread has no constructors defined

    MegaGreg wrote:[color=blue]
    > I'm trying to inherit from System.Diagnost ics.ProcessThre ad but I keep
    > getting the same error no matter what I try The namespace 'CSRSystem'
    > already contains a definition for 'Program'[/color]

    Well, that in itself is because you've got two different types called
    CSRSystem.Progr am, and it has nothing to do with the constructors.

    However, you're not going to be able to derive from ProcessThread, due
    to it not having any public or protected constructors.
    [color=blue]
    > I can't understand why the first one doesn't work. It's a public class,
    > there's nothing in the documentation about not being allowed to inherit
    > from it. I'm trying to get at the protected events member of this
    > class, hoping it will give me what I'm looking for.[/color]

    Whenever you want to derive from a class just to get at its protected
    members (rather than to really change its behaviour) you should get
    worried - chances are your design is flawed.
    [color=blue]
    > Maybe there's a better solution to my problem. I'm trying to respond to
    > a button click. The problem is that the button click is happening in
    > another program that I didn't write, and don't have the source code
    > for. Any solutions for the inheritance problem or the button click
    > problem on a whole?[/color]

    I don't think ProcessThread would help you anyway - but I think you'll
    have to delve deep into Win32 stuff to be able to respond to another
    process' Windows events.

    Jon

    Comment

    • Stoitcho Goutsev \(100\)

      #3
      Re: type ProcessThread has no constructors defined

      MegaGreg,

      You cannot inherit from this class. It is not sealed, but it has a internal
      constructor. I've no idea why this class inherits from Component, it is not
      a component at all.

      Anyways even if you could I don't think you can use to achieve your goals.

      What do you expect to get from its Events? You want find event for clicking
      on a button.

      I don't quite understand your problem. Do you have a running application and
      you want to respond to a button click in this application from another
      application?


      --

      Stoitcho Goutsev (100)
      "MegaGreg" <gregorydavies@ gmail.com> wrote in message
      news:1139923262 .074067.156800@ o13g2000cwo.goo glegroups.com.. .[color=blue]
      > I'm trying to inherit from System.Diagnost ics.ProcessThre ad but I keep
      > getting the same error no matter what I try:The namespace 'CSRSystem'
      > already contains a definition for 'Program'
      >
      > None of these pieces of code work:
      >
      > using System.Diagnost ics;
      > namespace CSRSystem {
      > class Program : ProcessThread{
      > }
      > }
      >
      > using System.Diagnost ics;
      > namespace CSRSystem {
      > class Program : ProcessThread{
      > Program() { }
      > }
      > }
      >
      > using System.Diagnost ics;
      > namespace CSRSystem {
      > class Program : ProcessThread{
      > Program() : base() { }
      > }
      > }
      >
      > I can't understand why the first one doesn't work. It's a public class,
      > there's nothing in the documentation about not being allowed to inherit
      > from it. I'm trying to get at the protected events member of this
      > class, hoping it will give me what I'm looking for.
      >
      > Maybe there's a better solution to my problem. I'm trying to respond to
      > a button click. The problem is that the button click is happening in
      > another program that I didn't write, and don't have the source code
      > for. Any solutions for the inheritance problem or the button click
      > problem on a whole?
      >[/color]


      Comment

      • MegaGreg

        #4
        Re: type ProcessThread has no constructors defined

        Woops, that was the wrong error message. I don't know how that ever got
        there, but you got it anyway that I was having a problem with there
        being no constructors in ProcessThread. I'm in the process of delving
        into the win32 stuff right now. This makes me wonder if there's an
        aspect weaver out there somewhere for C# that crosscuts at events...
        As it turns out http://www.codeproject.com/csharp/popupkiller.asp has
        what I was looking for.

        Comment

        Working...