Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. method delivers a structure, but there is no type that handles it... what do i do?

method delivers a structure, but there is no type that handles it... what do i do?

Scheduled Pinned Locked Moved C#
visual-studiocomquestion
9 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bbranded
    wrote on last edited by
    #1

    I'm unsure if my usage of terminology is proper. What I am doing is the following: 1) I am invoking the following method: GetOutboundBacklogFileIdRecords 2) This returns: [in] string VersionVector, [out] DfsrIdRecordInfo BacklogIdRecords[], [out] uint32 IdRecordIndex 3) DfsrIdRecordInfo contains an attribute that I'd like to get called FileName of type string. If I use object[] blah, then I can't assign blah["FileName"]. What do I do to access the FileName attribute? Thanks very much, Matt Brown

    R B 2 Replies Last reply
    0
    • B bbranded

      I'm unsure if my usage of terminology is proper. What I am doing is the following: 1) I am invoking the following method: GetOutboundBacklogFileIdRecords 2) This returns: [in] string VersionVector, [out] DfsrIdRecordInfo BacklogIdRecords[], [out] uint32 IdRecordIndex 3) DfsrIdRecordInfo contains an attribute that I'd like to get called FileName of type string. If I use object[] blah, then I can't assign blah["FileName"]. What do I do to access the FileName attribute? Thanks very much, Matt Brown

      R Offline
      R Offline
      riced
      wrote on last edited by
      #2

      The FileName in a DfsrIdRecordInfo is read only why do you want to assign to it?:confused: What type is blah? :confused: There is a GetFullFilePath Method, could this give you what you want?

      Regards David R

      B 1 Reply Last reply
      0
      • R riced

        The FileName in a DfsrIdRecordInfo is read only why do you want to assign to it?:confused: What type is blah? :confused: There is a GetFullFilePath Method, could this give you what you want?

        Regards David R

        B Offline
        B Offline
        bbranded
        wrote on last edited by
        #3

        blah is an object[] collection, an I'm attempting to use it to access the DfsrIdRecordInfo.GetFullFilePath.FileName string. DfsrIdRecordInfo is not a type, but apparently is a class. I am unsure how to handle accessing the DfsrIdRecordInfo.GetFullFilePath.FileName string within this. Again, DfsrIdRecordInfo is being returned from GetOutboundBacklogFileIdRecords. How do I do this? The DfsrIdRecordInfo.GetFullFilePath method would be an interesting extra feature, but querying the DFS DB on what could possibly be +500,000 files (although it would probably be limited far below this) for their full path would be fairly intensive. See this code for what I have written: pastebin However, ManagementObject has no GetEnumerator and can't be enumerated (foreach (ManagementObject returnedsub in returned)), so I am unsure how to access the the DfsrIfRecordInfo so that I can access it's properties. How do I do this? Thanks for your response, Matt

        modified on Friday, April 17, 2009 9:30 AM

        R 1 Reply Last reply
        0
        • B bbranded

          blah is an object[] collection, an I'm attempting to use it to access the DfsrIdRecordInfo.GetFullFilePath.FileName string. DfsrIdRecordInfo is not a type, but apparently is a class. I am unsure how to handle accessing the DfsrIdRecordInfo.GetFullFilePath.FileName string within this. Again, DfsrIdRecordInfo is being returned from GetOutboundBacklogFileIdRecords. How do I do this? The DfsrIdRecordInfo.GetFullFilePath method would be an interesting extra feature, but querying the DFS DB on what could possibly be +500,000 files (although it would probably be limited far below this) for their full path would be fairly intensive. See this code for what I have written: pastebin However, ManagementObject has no GetEnumerator and can't be enumerated (foreach (ManagementObject returnedsub in returned)), so I am unsure how to access the the DfsrIfRecordInfo so that I can access it's properties. How do I do this? Thanks for your response, Matt

          modified on Friday, April 17, 2009 9:30 AM

          R Offline
          R Offline
          riced
          wrote on last edited by
          #4

          Ok, I think I see what you're trying to do, so here goes. GetFullFilePath is a method of DfsrIdRecord that returns a string giving the full path. You can't get the file name using DfsrIdRecordInfo.GetFullFilePath.FileName. In your code you have:

          item.InvokeMethod("GetOutboundBacklogFileIdRecords", methodArgs);

          //get all members of returned
          // in the case of GetOutboundBacklogFileIdRecords
          // [0] = [in] string VersionVector,
          // [1] = [out] DfsrIdRecordInfo BacklogIdRecords[],
          // [2] = [out] uint32 IdRecordIndex

          This means that the second parameter should be an array of DfsrIdRecordInfo. I think you need something like this:

          DfsrIdRecordInfo [] blog = new DfsrIdRecordInfo []();
          uint32 lastID;
          Object[] methodArgs = {"your string", blog, lastID };

          When GetOutboundBacklogFileIdRecords returns the blog array will have the backlog DfsrIdRecordInfo records. you should then be able to iterate using something like:

          foreach(DfsrIdRecordInfo rec in blog)
          {
          string path = rec.GetFullFilePath();
          // chop it up to get filename and do whatever
          }

          Caveat - I've never used DfsrIdRecordInfo in my life :-D However from what I know of WMI and the MSDN documentation, that's what I would expect to do. :) Second caveat - there may be some typos in the code fragments.

          Regards David R

          B 1 Reply Last reply
          0
          • B bbranded

            I'm unsure if my usage of terminology is proper. What I am doing is the following: 1) I am invoking the following method: GetOutboundBacklogFileIdRecords 2) This returns: [in] string VersionVector, [out] DfsrIdRecordInfo BacklogIdRecords[], [out] uint32 IdRecordIndex 3) DfsrIdRecordInfo contains an attribute that I'd like to get called FileName of type string. If I use object[] blah, then I can't assign blah["FileName"]. What do I do to access the FileName attribute? Thanks very much, Matt Brown

            B Offline
            B Offline
            bbranded
            wrote on last edited by
            #5

            I think what I'm going to have to do is use Type and use Reflection! Type MSDN using System; using System.Reflection; class Example { static void Main() { Type t = typeof(String); MethodInfo substr = t.GetMethod("Substring", new Type[] { typeof(int), typeof(int) }); Object result = substr.Invoke("Hello, World!", new Object[] { 7, 5 }); Console.WriteLine("{0} returned \"{1}\".", substr, result); } } /* This code example produces the following output: System.String Substring(Int32, Int32) returned "World". */

            B 1 Reply Last reply
            0
            • R riced

              Ok, I think I see what you're trying to do, so here goes. GetFullFilePath is a method of DfsrIdRecord that returns a string giving the full path. You can't get the file name using DfsrIdRecordInfo.GetFullFilePath.FileName. In your code you have:

              item.InvokeMethod("GetOutboundBacklogFileIdRecords", methodArgs);

              //get all members of returned
              // in the case of GetOutboundBacklogFileIdRecords
              // [0] = [in] string VersionVector,
              // [1] = [out] DfsrIdRecordInfo BacklogIdRecords[],
              // [2] = [out] uint32 IdRecordIndex

              This means that the second parameter should be an array of DfsrIdRecordInfo. I think you need something like this:

              DfsrIdRecordInfo [] blog = new DfsrIdRecordInfo []();
              uint32 lastID;
              Object[] methodArgs = {"your string", blog, lastID };

              When GetOutboundBacklogFileIdRecords returns the blog array will have the backlog DfsrIdRecordInfo records. you should then be able to iterate using something like:

              foreach(DfsrIdRecordInfo rec in blog)
              {
              string path = rec.GetFullFilePath();
              // chop it up to get filename and do whatever
              }

              Caveat - I've never used DfsrIdRecordInfo in my life :-D However from what I know of WMI and the MSDN documentation, that's what I would expect to do. :) Second caveat - there may be some typos in the code fragments.

              Regards David R

              B Offline
              B Offline
              bbranded
              wrote on last edited by
              #6

              I work around some devs; I'm the "Network and Systems Engineer," hence all this DFSR talk. I was able to annoyingly tear one of them away from their work. She was able to aim me in the right direction of this (declaring the type DfsrIdRecordInfo). Except there is no type accessible DfsrIdRecordInfo to be assigned. See my response to myself (top of the tree) where I figured out that I'll probably get it by using Type and System.Reflection. :) Very interesting situation; and very good to know. Being this "Network and Systems Engineer" thing, I tend to use WMI for all my work, while you all (devs, like my co-workers who I incessantly ask questions) don't. WMI's interface is all sorts of weird. It's basically like if you stored a bunch of classes in an SQL DB instead of storing them in a class. Maybe I'm simply a novice, but I find that kinda weird. Apparently, Reflection is part of the .NET framework, so if that's an indication, I suppose it isn't weird. Hopefully this will work, and I'll post code when it does. Thanks, Matt

              modified on Friday, April 17, 2009 12:29 PM

              R 1 Reply Last reply
              0
              • B bbranded

                I work around some devs; I'm the "Network and Systems Engineer," hence all this DFSR talk. I was able to annoyingly tear one of them away from their work. She was able to aim me in the right direction of this (declaring the type DfsrIdRecordInfo). Except there is no type accessible DfsrIdRecordInfo to be assigned. See my response to myself (top of the tree) where I figured out that I'll probably get it by using Type and System.Reflection. :) Very interesting situation; and very good to know. Being this "Network and Systems Engineer" thing, I tend to use WMI for all my work, while you all (devs, like my co-workers who I incessantly ask questions) don't. WMI's interface is all sorts of weird. It's basically like if you stored a bunch of classes in an SQL DB instead of storing them in a class. Maybe I'm simply a novice, but I find that kinda weird. Apparently, Reflection is part of the .NET framework, so if that's an indication, I suppose it isn't weird. Hopefully this will work, and I'll post code when it does. Thanks, Matt

                modified on Friday, April 17, 2009 12:29 PM

                R Offline
                R Offline
                riced
                wrote on last edited by
                #7

                Good to here you've got some help :) I only know about WMI because I've played with it on my home network - don't do anything with it at work. :-D

                Regards David R

                B 1 Reply Last reply
                0
                • B bbranded

                  I think what I'm going to have to do is use Type and use Reflection! Type MSDN using System; using System.Reflection; class Example { static void Main() { Type t = typeof(String); MethodInfo substr = t.GetMethod("Substring", new Type[] { typeof(int), typeof(int) }); Object result = substr.Invoke("Hello, World!", new Object[] { 7, 5 }); Console.WriteLine("{0} returned \"{1}\".", substr, result); } } /* This code example produces the following output: System.String Substring(Int32, Int32) returned "World". */

                  B Offline
                  B Offline
                  bbranded
                  wrote on last edited by
                  #8

                  It doesn't appear that this will work, since c# is strongly typed, and typeof(known_type); where this is not a known type. However, maybe creating a strongly typed class for the WMI class will work: How To: Use Strongly-Typed Objects[^] MgmtClassGen.exe[^] [UPDATE] Here are the classes generated for windows 2003 r2 DFS-R[^]

                  modified on Friday, April 17, 2009 3:34 PM

                  1 Reply Last reply
                  0
                  • R riced

                    Good to here you've got some help :) I only know about WMI because I've played with it on my home network - don't do anything with it at work. :-D

                    Regards David R

                    B Offline
                    B Offline
                    bbranded
                    wrote on last edited by
                    #9

                    Hey David, I think I got it now. Since C# is strongly typed, you have to provide typing. Thank god that Microsoft made a tool (released within .NET framework 2.0 SDK) that does this. See my self reply: tool and finally... the class that contains the classes for DFS-R WMI namespace in Windows 2003 R2![^] :-D

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups