473,426 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,426 software developers and data experts.

Difficulties in using .Net dll in VB6 due to Int64 type in function parameters

I have gone through necessary step and have been able to use a .Net
libraries (created using C#) in VB6. It run good untill I try to use
certain function in the library that is using Int64 type as parameter.

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

Nov 23 '05 #1
5 5313

ha*********@gmail.com wrote:
I have gone through necessary step and have been able to use a .Net
libraries (created using C#) in VB6. It run good untill I try to use
certain function in the library that is using Int64 type as parameter.

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.


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

Nov 23 '05 #2
Hi,

I dont think int64 is supported in vb6. A .net int32 is the same
as the vb6 long.

http://msdn.microsoft.com/library/de...rdatatypes.asp

Ken
---------------------
<ha*********@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
I have gone through necessary step and have been able to use a .Net
libraries (created using C#) in VB6. It run good untill I try to use
certain function in the library that is using Int64 type as parameter.

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

Nov 23 '05 #3
If you can change the .dll as you suggest, you can create an overloaded
function that uses 2 longs..
i don't claim this is syntactilcy correct...but basicly you want: something
like

public void function VBFriendly(int high32bits, int low32bits)
{
// call the
ulong x = (high32bits << 32) + low32bits;

VBUnfriendly(x);
}
<ha*********@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
I have gone through necessary step and have been able to use a .Net
libraries (created using C#) in VB6. It run good untill I try to use
certain function in the library that is using Int64 type as parameter.

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

Nov 23 '05 #4
Thanks everyone.
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

Nov 23 '05 #5
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
<ha*********@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Thanks everyone.
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

Nov 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is...
11
by: truckaxle | last post by:
I am trying to pass a slice from a larger 2-dimensional array to a function that will work on a smaller region of the array space. The code below is a distillation of what I am trying to...
2
by: Einar Høst | last post by:
Hi, I'm reading data from a tape device using p/invoke. It's working pretty well, but when I'm trying to get data about the tape device, I'm doing something wrong. I believe it has something to...
1
by: Prasad Karunakaran | last post by:
I am using the C# DirectoryEntry class to retrieve the Properties of an user object in the Active Directory. I need to get the First Name and Last Name as properties. I know it is not supported...
4
by: Simon Devlin | last post by:
Hi folks, I've been bashing my head against this all afternoon and am now totally baffled. Given this (a simple routine to turn a ip address string into an decimal) <snip> Dim Parts(3) as...
14
by: cj | last post by:
VB2003. I need a large positive integer. Which is larger int64 or double? I see int64 also apparently is known as long and will hold -9,223,372,036,854,775,808 through...
0
by: Bhavesh | last post by:
Hello genious people, I m trying to insert a LARGE text from Multiline Textbox into my table of sqlserver2000. I m using vs-2005. Please note that I dont want to store blob data From FILE TO...
5
by: Bhavesh | last post by:
Hello genious people, I m trying to insert a LARGE text from Multiline Textbox into my table of sqlserver2000. I m using vs-2005. Please note that I dont want to store blob data From FILE...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.