I have referenced a C++ project to call a function from a class within but I get the error message "No overload for method "foo" takes '4' arguments" when I compile.
if I go to the deinition for the class of the following call: myClass.foo(a, b, ref c, d)
I can see the following metadata:
namespace SPTI
{
public class myClass{
public myClass();
public static bool foo(Target a, byte[] b, byte[] c, bool d);
}
}
With the following for the declaration in C++:
static bool myClass::foo([Runtime::InteropServices::In]SESTool::Target a,
[Runtime::InteropServices::In]array<Byte>^ b,
[Runtime::InteropServices::In, Runtime::InteropServices::Out]array<Byte>^ c,
[Runtime::InteropServices::In]bool d);
I also noticed that autocomplete will not list that function from within that particular file (it will autocomplete in other files in the C# project but not build). Is there something that I am forgetting to include I'm completely stumped on this one.
Thanks,
Devan

Error: "No overload for method "foo" takes '4' arguments"
Tryst
I had thought that [Runtime::InteropServices::In, Runtime::InteropServices::Out]^ implied ref. Please correct me if I'm wrong as I don't know that there is a "ref" keyword in C++. The error is complaining that no function exists with 4 arguments, it does not mention a type mismatch. :(
rajender reddy
I thought using Runtime::InteropServices::In, Runtime::InteropServices::Out meant using "ref" in C#:
myClass.myFunc(a, b, ref c, d);
But, there is an error for that; "no overload that takes 4 parameters" seems strange.
Are you missing a reference caret (^) on the Target argument of the myFunc declaration
Jonathon Stevens
Appologies for being so brief before, I actually wasn't near the code.
Made an example solution today with the same problem.
The Solution comtains two projects, a C# project (InteropExample) and a C++ project (myClass).
Inside the C++ project is one file (aside from stdafx), myClass.cpp.
Inside the C# project are two non-default files, Program.cs and Target.cs.
The C++ project has a reference to the executible object of the C# project while the C# project has a reference to the C++ project, this was done to eliminate circular dependencies but allow the C++ project to access the C# defined classes. In InteropExample a call is made to a static method of myClass (myCPPNamespace::myClass.myFunc) that requires 4 parameters. When I attempt to compile I get an error "No Overload for method 'myFunc' takes '4' arguments," the metadata produced from Program.cs with "Go To Definition" shows the expected function.
Here are some of the files:
Program.cs:
myClass.cpp:
Target.cs:
myClass[from metadata]:
dxx
It's probably because there is no overload that takes those types of 4 arguments.
See Short but complete programs on how to post code samples that provide enough information for someone to accurately help you.
ehsan707
chaza
For the example above the line is:
return myClass.foo(a, b, ref c, d);
In the test code the line looks more like this:
return SPTIWrapper.SendAspi32Command(target, cdb, ref buffer, write);
where Target target, byte [] cdb, ref byte[] buffer, bool write
Devan
su45937
isaacb
Juergen Lorenz
The caret on 'target'
AlexBB