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
  1. Home
  2. General Programming
  3. C#
  4. No overload for method 'PassStructIn' takes 4 arguments

No overload for method 'PassStructIn' takes 4 arguments

Scheduled Pinned Locked Moved C#
helptutorialquestion
7 Posts 3 Posters 7 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.
  • M Offline
    M Offline
    Member 12244972
    wrote on last edited by
    #1

    And in my usual fashion of cobbling together source codes before I have grasped the concepts, I give you this glorious error:

    No overload for method 'PassStructIn' takes 4 arguments

    The code in question happens to be a call to an unmanaged dll:

    class Program
    {
    public struct Quaternion
    {
    double w; double x; double y; double z;
    }

      \[DllImport("YLScsDrawing.dll")\]
      public static extern void PassStructIn(ref Quaternion myQuaternion);
    
        static void Main(string\[\] args)
        {
        Program.Quaternion myQuaternion;
        Program.PassStructIn(ref myQuaternion);
    
        //Yada Yada Yada
    
        //Then the threading of said function...
    
        // Abs threads
        Thread absoluteThread = new Thread(unused => Program.PassStructIn((double)absW, (double)absX, (double)absY, (double)absZ));
        absoluteThread.Start();
      	// Abs threads
    

    Please advise on how to fix this... Thanks.

    L OriginalGriffO 2 Replies Last reply
    0
    • M Member 12244972

      And in my usual fashion of cobbling together source codes before I have grasped the concepts, I give you this glorious error:

      No overload for method 'PassStructIn' takes 4 arguments

      The code in question happens to be a call to an unmanaged dll:

      class Program
      {
      public struct Quaternion
      {
      double w; double x; double y; double z;
      }

        \[DllImport("YLScsDrawing.dll")\]
        public static extern void PassStructIn(ref Quaternion myQuaternion);
      
          static void Main(string\[\] args)
          {
          Program.Quaternion myQuaternion;
          Program.PassStructIn(ref myQuaternion);
      
          //Yada Yada Yada
      
          //Then the threading of said function...
      
          // Abs threads
          Thread absoluteThread = new Thread(unused => Program.PassStructIn((double)absW, (double)absX, (double)absY, (double)absZ));
          absoluteThread.Start();
        	// Abs threads
      

      Please advise on how to fix this... Thanks.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You'd need to know how many arguments are expected. The code complains that there is no method accepting four arguments. I'd also advise against using a lambda to start a thread.

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

      1 Reply Last reply
      0
      • M Member 12244972

        And in my usual fashion of cobbling together source codes before I have grasped the concepts, I give you this glorious error:

        No overload for method 'PassStructIn' takes 4 arguments

        The code in question happens to be a call to an unmanaged dll:

        class Program
        {
        public struct Quaternion
        {
        double w; double x; double y; double z;
        }

          \[DllImport("YLScsDrawing.dll")\]
          public static extern void PassStructIn(ref Quaternion myQuaternion);
        
            static void Main(string\[\] args)
            {
            Program.Quaternion myQuaternion;
            Program.PassStructIn(ref myQuaternion);
        
            //Yada Yada Yada
        
            //Then the threading of said function...
        
            // Abs threads
            Thread absoluteThread = new Thread(unused => Program.PassStructIn((double)absW, (double)absX, (double)absY, (double)absZ));
            absoluteThread.Start();
          	// Abs threads
        

        Please advise on how to fix this... Thanks.

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #3

        You define PassStructIn as taking a single parameter: a reference to a structure you defined above. Then you try to call it by passing four parameters...and you are surprised you get an error? Create an instance of the struct and fill in it's fields. Then pass the ref struct to the external method.

        Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        M 1 Reply Last reply
        0
        • OriginalGriffO OriginalGriff

          You define PassStructIn as taking a single parameter: a reference to a structure you defined above. Then you try to call it by passing four parameters...and you are surprised you get an error? Create an instance of the struct and fill in it's fields. Then pass the ref struct to the external method.

          Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

          M Offline
          M Offline
          Member 12244972
          wrote on last edited by
          #4

          Perhaps showing the code for the dll will help...

          using System;
          using System.Collections.Generic;
          using System.Text;

          namespace YLScsDrawing.Drawing3d
          {
          public struct Quaternion
          {
          public double X, Y, Z, W;

              public Quaternion(double w, double x, double y, double z)// This is the set of parameters I wish to call...
              {
                  W = w; X = x; Y = y; Z = z;
              }
           }
          

          }

          Any suggestions?

          OriginalGriffO 1 Reply Last reply
          0
          • M Member 12244972

            Perhaps showing the code for the dll will help...

            using System;
            using System.Collections.Generic;
            using System.Text;

            namespace YLScsDrawing.Drawing3d
            {
            public struct Quaternion
            {
            public double X, Y, Z, W;

                public Quaternion(double w, double x, double y, double z)// This is the set of parameters I wish to call...
                {
                    W = w; X = x; Y = y; Z = z;
                }
             }
            

            }

            Any suggestions?

            OriginalGriffO Offline
            OriginalGriffO Offline
            OriginalGriff
            wrote on last edited by
            #5

            Well... you could always try:

            Quaternion quat = new Quaternion ((double)absW, (double)absX, (double)absY, (double)absZ));
            Thread absoluteThread = new Thread(unused => Program.PassStructIn(ref quat);

            Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

            "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
            "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

            M 1 Reply Last reply
            0
            • OriginalGriffO OriginalGriff

              Well... you could always try:

              Quaternion quat = new Quaternion ((double)absW, (double)absX, (double)absY, (double)absZ));
              Thread absoluteThread = new Thread(unused => Program.PassStructIn(ref quat);

              Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

              M Offline
              M Offline
              Member 12244972
              wrote on last edited by
              #6

              The line of code...

              Quaternion quat = new Quaternion ((double)absW, (double)absX, (double)absY, (double)absZ);

              Brings up the following error.

              'Siren.Program.Quaternion' does not contain a constructor that takes 4 arguments

              Any other ideas?

              OriginalGriffO 1 Reply Last reply
              0
              • M Member 12244972

                The line of code...

                Quaternion quat = new Quaternion ((double)absW, (double)absX, (double)absY, (double)absZ);

                Brings up the following error.

                'Siren.Program.Quaternion' does not contain a constructor that takes 4 arguments

                Any other ideas?

                OriginalGriffO Offline
                OriginalGriffO Offline
                OriginalGriff
                wrote on last edited by
                #7

                According to your code sample it does:

                public struct Quaternion
                {
                public double X, Y, Z, W;

                public Quaternion(double w, double x, double y, double z)// This is the set of parameters I wish to call...
                {
                    W = w; X = x; Y = y; Z = z;
                }
                

                }

                If that is in a separate DLL, then I'd suggest that you check you are referencing the latest version, and that it compiles without errors. Because your code samples are referring to different struct names: Siren.Program.Quaternion in the error message instead of the code sample YLScsDrawing.Drawing3d.Quaternion

                Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...

                "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                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