|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Re-flunk-tion!I'm wondering why reflection fails in this instance... I'm trying to do drag
and drop using ListViewItem objects. When I check the DragEventArgs to see if it has my ListViewItem, I have to use GetDataPresent to test if it's the data I'm looking for. I have to pass a System.Type object representing the type of a ListViewItem object. But I've found that Type fails to correctly identify a ListViewItem. If I try this: Type f = Type.GetType("System.Windows.Forms.ListViewItem"); f is null. According to MSDN, this should work, as their sample is this: Type myType1 = Type.GetType("System.Int32"); Am I wrong? What's going on? William Sullivan <WilliamSulli***@discussions.microsoft.com> wrote:
> I'm wondering why reflection fails in this instance... I'm trying to do drag You're wrong, because you didn't spot the bit of the documentation > and drop using ListViewItem objects. When I check the DragEventArgs to see > if it has my ListViewItem, I have to use GetDataPresent to test if it's the > data I'm looking for. I have to pass a System.Type object representing the > type of a ListViewItem object. But I've found that Type fails to correctly > identify a ListViewItem. If I try this: > Type f = Type.GetType("System.Windows.Forms.ListViewItem"); > f is null. According to MSDN, this should work, as their sample is this: > Type myType1 = Type.GetType("System.Int32"); > > Am I wrong? What's going on? which states: <quote> If typeName includes only the name of the Type, this method searches in the calling object's assembly, then in the mscorlib.dll assembly. If typeName is fully qualified with the partial or complete assembly name, this method searches in the specified assembly. </quote> Int32 is part of mscorlib; ListViewItem isn't. -- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too Okay, so what's the "fully qualifed with the partial or complete assembly
name" of ListViewItem? I'm interested because I thought that "System.Windows.Forms.ListViewItem" was fully qualified. Show quoteHide quote "Jon Skeet [C# MVP]" wrote: > William Sullivan <WilliamSulli***@discussions.microsoft.com> wrote: > > I'm wondering why reflection fails in this instance... I'm trying to do drag > > and drop using ListViewItem objects. When I check the DragEventArgs to see > > if it has my ListViewItem, I have to use GetDataPresent to test if it's the > > data I'm looking for. I have to pass a System.Type object representing the > > type of a ListViewItem object. But I've found that Type fails to correctly > > identify a ListViewItem. If I try this: > > Type f = Type.GetType("System.Windows.Forms.ListViewItem"); > > f is null. According to MSDN, this should work, as their sample is this: > > Type myType1 = Type.GetType("System.Int32"); > > > > Am I wrong? What's going on? > > You're wrong, because you didn't spot the bit of the documentation > which states: > > <quote> > If typeName includes only the name of the Type, this method searches in > the calling object's assembly, then in the mscorlib.dll assembly. If > typeName is fully qualified with the partial or complete assembly name, > this method searches in the specified assembly. > </quote> > > Int32 is part of mscorlib; ListViewItem isn't. > > -- > Jon Skeet - <sk***@pobox.com> > http://www.pobox.com/~skeet > If replying to the group, please do not mail me too > William Sullivan <WilliamSulli***@discussions.microsoft.com> wrote:
> Okay, so what's the "fully qualifed with the partial or complete assembly System.Windows.Forms.ListViewItem, System.Windows.Forms, Version=> name" of ListViewItem? 1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 > I'm interested because I thought that It's fully qualified in terms of namespace, but not assembly.> "System.Windows.Forms.ListViewItem" was fully qualified. -- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too Jon Skeet [C# MVP] <sk***@pobox.com> wrote in message news:<MPG.1c0e410a97293a7998b985@msnews.microsoft.com>... If you just want to get the type, use this:> William Sullivan <WilliamSulli***@discussions.microsoft.com> wrote: > > Okay, so what's the "fully qualifed with the partial or complete assembly > > name" of ListViewItem? > > System.Windows.Forms.ListViewItem, System.Windows.Forms, Version= > 1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 > > > I'm interested because I thought that > > "System.Windows.Forms.ListViewItem" was fully qualified. > > It's fully qualified in terms of namespace, but not assembly. Type t = typeof(System.Windows.Forms.ListView); Tommy Carlier <tommy.carl***@telenet.be> wrote:
> > > I'm interested because I thought that That's fine if you know the type name at compile time, but typically > > > "System.Windows.Forms.ListViewItem" was fully qualified. > > > > It's fully qualified in terms of namespace, but not assembly. > > If you just want to get the type, use this: > Type t = typeof(System.Windows.Forms.ListView); that isn't the situation when this kind of problem arises. -- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too Jon Skeet [C# MVP] <sk***@pobox.com> wrote in message news:<MPG.1c0e410a97293a7998b985@msnews.microsoft.com>... If you just want to get the type, use this:> William Sullivan <WilliamSulli***@discussions.microsoft.com> wrote: > > Okay, so what's the "fully qualifed with the partial or complete assembly > > name" of ListViewItem? > > System.Windows.Forms.ListViewItem, System.Windows.Forms, Version= > 1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 > > > I'm interested because I thought that > > "System.Windows.Forms.ListViewItem" was fully qualified. > > It's fully qualified in terms of namespace, but not assembly. Type t = typeof(System.Windows.Forms.ListView);
Other interesting topics
w3wp.exe locking DLL and PDB files.
Reverse usage of public/private RSA encryption keys for licensing? regex puzzle! Multithreading and RollBacks Starting up application from dll. ASP.NET 2.0 Maintain Scroll Position on PostBack with Mozilla FIREFOX in the works? ANN: Bob Powell's Beginners Guide to GDI+ How to read Outlook attachments in .NET ? Monitor (lock) Anyone have info on the dreaded Q316146 bug? ... (i.e. There is no Original data to access) |
|||||||||||||||||||||||