VB6 give the following error
Compile Error:
Function or interface marked as restricted, or the function use an
automation type not supported in Visual Basic.
There must be something that can be done either on C# side or VB6 side.
Please advise.
Here is some code (not exactly but modified here and there)
IN C#
=====================================================
public interface ITesting
{
bool TestConnect(string strc, string usr, string pwd);
void TestDisconnect();
bool Start(bool boolparam);
bool TestCheck(Int64 param1, Int64 param2);
}
//bla bla bla
...
public class Testing : ITesting
{
//bla bla bla
...
public bool TestCheck(Int64 param1, Int64 param2)
{
//bla bla bla
...
}
//bla bla bla
...
}
Thanks in advance,
Haris
Try using the Currency type on the VB6 side. If it does work, you will
have to go through fun and games with CopyMemory and the like to get
64-bit integer values into and out of the Currency.
Credit to Bruce McKinney if it works :)
--
Larry Lard
Replies to group please
I dont think int64 is supported in vb6. A .net int32 is the same
as the vb6 long.
Ken
---------------------
<haris...@gmail.com> wrote in message
news:1131531624....@o13g2000cwo.googlegroups.com...
public void function VBFriendly(int high32bits, int low32bits)
{
// call the
ulong x = (high32bits << 32) + low32bits;
VBUnfriendly(x);
}
<haris...@gmail.com> wrote in message
news:1131531624....@o13g2000cwo.googlegroups.com...
>From the replies I can summarize that either change VB code by
converting Int64 to Currency or something else useable by VB or create
another function in C# dll that expose int to VB yet call the function
with Int64 parameters.
Actually I am trying to avoid both solution. I was thinking more in the
line of changing the ITesting interface declaration.
I have tried to do this:
public interface ITesting
{
bool TestConnect(string strc, string usr, string pwd);
void TestDisconnect();
bool Start(bool boolparam);
//bool TestCheck(Int64 param1, Int64 param2);
bool TestCheck(int param1, int param2);
//Int64 TestID{get;}
int TestID{get;}
}
There is two error:
'Testing' does not implement interface member 'ITesting.TestCheck(int,
int)'
'Testing' does not implement interface member 'ITesting.TestID'.
'Testing.TestID' is either static, not public, or has the wrong return
type.
I can understand why the error is given. Just wondering is there a work
around for this? If this cannot be done appreciate some explanation on
why it cannot be done.
Thanks and regards,
Haris
Since you changed your interface, you will also need to change the class
that implements it. If you can't change that class, you will need to change
the interface back to what it was before, and find another work around.
Assuming you CANNOT change the class and interface to be VB friendly (either
by modifying existing calls, or adding new ones), I think your only option
would be to create a small helper .dll in C# to make the call for you. To
tell the truth, I've not created a C# dll to be compatable with VB 6... but
here's the meat of it...esentially the same suggestion I mentioned earlier,
but now using your parametrs
[whatever attributes necessary to make COM compliant]
class ITestingVB6Adapter
{
[whatever attributes necessary to make COM compliant]
public bool TestCheck(
ITesting testing, // testing object to make the call against
int param1_hi, // high-order 32 bits of 64 bit param1
int param1_lo, // low-order 32 bits of 64 bit param1
int param2_hi, // high-order 32 bits of 64 bit param2
int param2_lo) // low-order 32 bits of 64 bit param2
{
Int64 param1;
Int64 param2;
param1 = param1_hi; // assign high order bits
param1 = param1 << 32; // shift up
param1 = param1 + param1_lo; // add low order bits
param2 = param2_hi; // assign high order bits
param2 = param2 << 32; // shift up
param2 = param2 + param2_lo; // add low order bits
// return result of object method
return testing.TestCheck(param1, param2);
}
}
In VB you would call this passing your object and methods.
Dim oT As new ITesting
Dim oH As new ITestingVB6Adapter
Dim b as Boolean
Dim param1 As Long
Dim param2 As Long
param1 = 1234567
param2 = 7654321
// since VB Long's are 32 bit numbers, you can always pass 0 for high 32
bits
// if you need real 64 bit values, you will have to work out the math
somehow.
b = oH.TestCheck(oT, 0, param1, 0, param2)
Hope this helps
<haris...@gmail.com> wrote in message
news:1131590057.2...@g47g2000cwa.googlegroups.com...