BUG Compiler

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Guest's Avatar

    #1

    BUG Compiler

    Hi,

    Repro:

    Make a call to the Cursor ctor like this.Cursor = new Cursor(GetType( ),
    "SomeCur.cu r");

    DO NOT have the following line in the program... using System.Reflecti on;

    Watch the Cursor ctro FAIL yet no compiler warning.

    Add the using System.Reflecti on; reference

    Build, again no compiler errror or warning (this time correctly) and call
    the Cursor ctor, it succeeds.

    Why no compiler warning or error?

    Thanks.


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: BUG Compiler

    The line:

    using System.Reflecti on;

    Is not actually setting a reference, but rather, it is declaring the
    shorthand for a namespace, which is different.

    What is the error that you are getting when you call it?


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    <discussion@dis cussion.microso ft.com> wrote in message
    news:uu8cmXBtDH A.2136@TK2MSFTN GP10.phx.gbl...[color=blue]
    > Hi,
    >
    > Repro:
    >
    > Make a call to the Cursor ctor like this.Cursor = new Cursor(GetType( ),
    > "SomeCur.cu r");
    >
    > DO NOT have the following line in the program... using[/color]
    System.Reflecti on;[color=blue]
    >
    > Watch the Cursor ctro FAIL yet no compiler warning.
    >
    > Add the using System.Reflecti on; reference
    >
    > Build, again no compiler errror or warning (this time correctly) and[/color]
    call[color=blue]
    > the Cursor ctor, it succeeds.
    >
    > Why no compiler warning or error?
    >
    > Thanks.
    >
    >[/color]


    Comment

    • Guest's Avatar

      #3
      Re: BUG Compiler

      ArgumentNullExc eption.

      Yet it is perfectly correct parameters. Works fine with the using
      System.Reflecti on but craps out without it.



      "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om> wrote in
      message news:%23ucsWaCt DHA.3492@TK2MSF TNGP11.phx.gbl. ..[color=blue]
      > The line:
      >
      > using System.Reflecti on;
      >
      > Is not actually setting a reference, but rather, it is declaring the
      > shorthand for a namespace, which is different.
      >
      > What is the error that you are getting when you call it?
      >
      >
      > --
      > - Nicholas Paldino [.NET/C# MVP]
      > - mvp@spam.guard. caspershouse.co m
      >
      > <discussion@dis cussion.microso ft.com> wrote in message
      > news:uu8cmXBtDH A.2136@TK2MSFTN GP10.phx.gbl...[color=green]
      > > Hi,
      > >
      > > Repro:
      > >
      > > Make a call to the Cursor ctor like this.Cursor = new[/color][/color]
      Cursor(GetType( ),[color=blue][color=green]
      > > "SomeCur.cu r");
      > >
      > > DO NOT have the following line in the program... using[/color]
      > System.Reflecti on;[color=green]
      > >
      > > Watch the Cursor ctro FAIL yet no compiler warning.
      > >
      > > Add the using System.Reflecti on; reference
      > >
      > > Build, again no compiler errror or warning (this time correctly) and[/color]
      > call[color=green]
      > > the Cursor ctor, it succeeds.
      > >
      > > Why no compiler warning or error?
      > >
      > > Thanks.
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Jon Skeet [C# MVP]

        #4
        Re: BUG Compiler

        <discussion@dis cussion.microso ft.com> wrote:[color=blue]
        > ArgumentNullExc eption.
        >
        > Yet it is perfectly correct parameters. Works fine with the using
        > System.Reflecti on but craps out without it.[/color]

        That seems very unlikely to me. Could you post a short but complete
        program which demonstrates the problem?

        See http://www.pobox.com/~skeet/csharp/complete.html for what I mean.

        --
        Jon Skeet - <skeet@pobox.co m>
        Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

        If replying to the group, please do not mail me too

        Comment

        • Alvin Bruney

          #5
          Re: BUG Compiler

          why dont you just code what he said numbnuts

          "Jon Skeet [C# MVP]" <skeet@pobox.co m> wrote in message
          news:MPG.1a2efb cb30da0176989b4 6@msnews.micros oft.com...[color=blue]
          > <discussion@dis cussion.microso ft.com> wrote:[color=green]
          > > ArgumentNullExc eption.
          > >
          > > Yet it is perfectly correct parameters. Works fine with the using
          > > System.Reflecti on but craps out without it.[/color]
          >
          > That seems very unlikely to me. Could you post a short but complete
          > program which demonstrates the problem?
          >
          > See http://www.pobox.com/~skeet/csharp/complete.html for what I mean.
          >
          > --
          > Jon Skeet - <skeet@pobox.co m>
          > http://www.pobox.com/~skeet
          > If replying to the group, please do not mail me too[/color]


          Comment

          • Willy Denoyette [MVP]

            #6
            Re: BUG Compiler

            IMO this has nothing to do with Reflection, take a look at your call stack,
            probably your resource name is different from the one you used to embed the
            cursor resource, resuling in a nullreference exception for the (embedded)
            stream.

            try this:

            using System;
            using System.Windows. Forms;
            using System.Drawing;
            namespace HelpCursor
            {
            class CursorForm : Form
            {
            static void Main()
            {
            CursorForm form = new CursorForm();
            form.Text = "Hello";
            form.BackColor = Color.Blue;
            form.Paint += new PaintEventHandl er(form.HelloPa intHandler);
            Application.Run (form);

            }
            void HelloPaintHandl er(object sender, PaintEventArgs args)
            {
            CursorForm form = sender as CursorForm;
            Graphics grp = args.Graphics;
            grp.DrawString( "Setting help cursor", form.Font, Brushes.Black, 0, 0);
            this.Cursor = new Cursor(GetType( ), @"Help.Cur") ;
            }
            }
            }

            compile with : csc /t:winexe cursp1.cs /res:help,HelpCu rsor.Help.Cur
            the help.cur file from the VS distribution(or any other cursor file).


            Willy.

            <discussion@dis cussion.microso ft.com> wrote in message
            news:uu8cmXBtDH A.2136@TK2MSFTN GP10.phx.gbl...[color=blue]
            > Hi,
            >
            > Repro:
            >
            > Make a call to the Cursor ctor like this.Cursor = new Cursor(GetType( ),
            > "SomeCur.cu r");
            >
            > DO NOT have the following line in the program... using[/color]
            System.Reflecti on;[color=blue]
            >
            > Watch the Cursor ctro FAIL yet no compiler warning.
            >
            > Add the using System.Reflecti on; reference
            >
            > Build, again no compiler errror or warning (this time correctly) and[/color]
            call[color=blue]
            > the Cursor ctor, it succeeds.
            >
            > Why no compiler warning or error?
            >
            > Thanks.
            >
            >[/color]


            Comment

            • Pete Davis

              #7
              Re: BUG Compiler

              First of all, with your attitude, you don't really deserve a response, but
              Jon is likely to code it correctly. If the original poster has coded it
              incorrectly, the only way to know is if he posts the code, numbnuts!


              "Alvin Bruney" <alvin.bruney@. telia.com.> wrote in message
              news:%23qfIqpEt DHA.628@tk2msft ngp13.phx.gbl.. .[color=blue]
              > why dont you just code what he said numbnuts
              >
              > "Jon Skeet [C# MVP]" <skeet@pobox.co m> wrote in message
              > news:MPG.1a2efb cb30da0176989b4 6@msnews.micros oft.com...[color=green]
              > > <discussion@dis cussion.microso ft.com> wrote:[color=darkred]
              > > > ArgumentNullExc eption.
              > > >
              > > > Yet it is perfectly correct parameters. Works fine with the using
              > > > System.Reflecti on but craps out without it.[/color]
              > >
              > > That seems very unlikely to me. Could you post a short but complete
              > > program which demonstrates the problem?
              > >
              > > See http://www.pobox.com/~skeet/csharp/complete.html for what I mean.
              > >
              > > --
              > > Jon Skeet - <skeet@pobox.co m>
              > > http://www.pobox.com/~skeet
              > > If replying to the group, please do not mail me too[/color]
              >
              >[/color]


              Comment

              • Alvin Bruney

                #8
                Re: BUG Compiler

                Temper temper :P


                "Pete Davis" <pdavis68@hotma il.com> wrote in message
                news:cef7a8ccf6 c3a3f26399edf88 d321688@news.me ganetnews.com.. .[color=blue]
                > First of all, with your attitude, you don't really deserve a response, but
                > Jon is likely to code it correctly. If the original poster has coded it
                > incorrectly, the only way to know is if he posts the code, numbnuts!
                >
                >
                > "Alvin Bruney" <alvin.bruney@. telia.com.> wrote in message
                > news:%23qfIqpEt DHA.628@tk2msft ngp13.phx.gbl.. .[color=green]
                > > why dont you just code what he said numbnuts
                > >
                > > "Jon Skeet [C# MVP]" <skeet@pobox.co m> wrote in message
                > > news:MPG.1a2efb cb30da0176989b4 6@msnews.micros oft.com...[color=darkred]
                > > > <discussion@dis cussion.microso ft.com> wrote:
                > > > > ArgumentNullExc eption.
                > > > >
                > > > > Yet it is perfectly correct parameters. Works fine with the using
                > > > > System.Reflecti on but craps out without it.
                > > >
                > > > That seems very unlikely to me. Could you post a short but complete
                > > > program which demonstrates the problem?
                > > >
                > > > See http://www.pobox.com/~skeet/csharp/complete.html for what I mean.
                > > >
                > > > --
                > > > Jon Skeet - <skeet@pobox.co m>
                > > > http://www.pobox.com/~skeet
                > > > If replying to the group, please do not mail me too[/color]
                > >
                > >[/color]
                >
                >[/color]


                Comment

                • 100

                  #9
                  Re: BUG Compiler

                  Hi,
                  I haven't got this particular Cursor constructor working either. I think
                  there is some problem in the Cursor class.
                  Actually, I haven't tried hard.
                  To load a cursor from resource get the cursor resouce as a stream and use
                  Cursor's constructor which accepts
                  streams.

                  I don't see any reason to have "using System.Reflecti on" line since you
                  don't use any type defined in this namespace.

                  HTH
                  B\rgds
                  100

                  <discussion@dis cussion.microso ft.com> wrote in message
                  news:uu8cmXBtDH A.2136@TK2MSFTN GP10.phx.gbl...[color=blue]
                  > Hi,
                  >
                  > Repro:
                  >
                  > Make a call to the Cursor ctor like this.Cursor = new Cursor(GetType( ),
                  > "SomeCur.cu r");
                  >
                  > DO NOT have the following line in the program... using[/color]
                  System.Reflecti on;[color=blue]
                  >
                  > Watch the Cursor ctro FAIL yet no compiler warning.
                  >
                  > Add the using System.Reflecti on; reference
                  >
                  > Build, again no compiler errror or warning (this time correctly) and[/color]
                  call[color=blue]
                  > the Cursor ctor, it succeeds.
                  >
                  > Why no compiler warning or error?
                  >
                  > Thanks.
                  >
                  >[/color]


                  Comment

                  • Stu Smith

                    #10
                    Re: BUG Compiler

                    You're the fake Alvin Bruney, right, as opposed to the clever one?
                    Can you keep your email constant so I don't have to keep adding you to my
                    kill-file?


                    "Alvin Bruney" <alvin.bruney@. telia.com.> wrote in message
                    news:%23qfIqpEt DHA.628@tk2msft ngp13.phx.gbl.. .[color=blue]
                    > why dont you just code what he said numbnuts
                    >
                    > "Jon Skeet [C# MVP]" <skeet@pobox.co m> wrote in message
                    > news:MPG.1a2efb cb30da0176989b4 6@msnews.micros oft.com...[color=green]
                    > > <discussion@dis cussion.microso ft.com> wrote:[color=darkred]
                    > > > ArgumentNullExc eption.
                    > > >
                    > > > Yet it is perfectly correct parameters. Works fine with the using
                    > > > System.Reflecti on but craps out without it.[/color]
                    > >
                    > > That seems very unlikely to me. Could you post a short but complete
                    > > program which demonstrates the problem?
                    > >
                    > > See http://www.pobox.com/~skeet/csharp/complete.html for what I mean.
                    > >
                    > > --
                    > > Jon Skeet - <skeet@pobox.co m>
                    > > http://www.pobox.com/~skeet
                    > > If replying to the group, please do not mail me too[/color]
                    >
                    >[/color]


                    Comment

                    • Alvin Bruney

                      #11
                      Re: BUG Compiler

                      Yes sir overlord

                      whatever you say sir overlord.

                      3 bags full overlord


                      "Stu Smith" <stuarts@remove .digita.com> wrote in message
                      news:Ot4QSqctDH A.3468@TK2MSFTN GP11.phx.gbl...[color=blue]
                      > You're the fake Alvin Bruney, right, as opposed to the clever one?
                      > Can you keep your email constant so I don't have to keep adding you to my
                      > kill-file?
                      >
                      >
                      > "Alvin Bruney" <alvin.bruney@. telia.com.> wrote in message
                      > news:%23qfIqpEt DHA.628@tk2msft ngp13.phx.gbl.. .[color=green]
                      > > why dont you just code what he said numbnuts
                      > >
                      > > "Jon Skeet [C# MVP]" <skeet@pobox.co m> wrote in message
                      > > news:MPG.1a2efb cb30da0176989b4 6@msnews.micros oft.com...[color=darkred]
                      > > > <discussion@dis cussion.microso ft.com> wrote:
                      > > > > ArgumentNullExc eption.
                      > > > >
                      > > > > Yet it is perfectly correct parameters. Works fine with the using
                      > > > > System.Reflecti on but craps out without it.
                      > > >
                      > > > That seems very unlikely to me. Could you post a short but complete
                      > > > program which demonstrates the problem?
                      > > >
                      > > > See http://www.pobox.com/~skeet/csharp/complete.html for what I mean.
                      > > >
                      > > > --
                      > > > Jon Skeet - <skeet@pobox.co m>
                      > > > http://www.pobox.com/~skeet
                      > > > If replying to the group, please do not mail me too[/color]
                      > >
                      > >[/color]
                      >
                      >[/color]


                      Comment

                      Working...