473,657 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trouble passing VARIANT array to a COM Server [VB.NET]

Hello Everybody

I have an C++ COM DLL with the following implementation.

__interface ICPM : IDispatch
{
HRESULT GlobalComputeCl ass ([in] VARIANT *inArr, [out,retval]double
*pval);
}
The VARIANT array gets accessed as in the function as

STDMETHODIMP CMP::GlobalComp uteClass (VARIANT *inArr, double *pVal) {
// Trying to access the the double array
double *internalArray;
if (SafeArrayAcces sData(*inArr->pparray, (void
HUGEP**)&intern alArray) != S_OK) {
cout << "Unable to access input array"<<endl;
}
....
}

Im trying to access this under VB.NET

Dim m_cpm As CPMLibrary.CPM
m_cpm = New CPMLibrary.CPCM
Dim InputParam(5) As Double
InputParam(0) = 1.1
InputParam(1) = 2.2
InputParam(2) = 3.3
InputParam(3) = 4.4
InputParam(4) = 5.5

Dim returnval As Double
returnval = m_cpm.GlobalCom puteClass (New Object () {InputParam})

^^^^^^^^^^^

Here the code breaks and complains

"An unhandled exception of type 'System.NullRef erenceException '
occurred in testing.exe

Additional information: Object reference not set to an instance of an
object."

The same code works fine with Excel VBScript Macro.

Can someone give me some advice on this issue ?

Thanks

Cheers
Sathya

Nov 21 '05 #1
0 2074

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

Similar topics

2
4872
by: Raoul | last post by:
I wrote a COM server object in C++ a few months ago. I can use it from Visual Basic, Visual C++, S-Plus and a number of other scripting environments. What I can't do is use it with my FAVOURITE scripting language, Python. I have tried everything by I'm going crazy here. Here is what I have...
3
8468
by: Henry | last post by:
Hi, I need to pass an array to a function, change it a little and return it to the main code. When i try it the webpage is displayed up until the function call. Nothing after that is displayed. When debugging in VS 6 it says: "An exception of type 'Error in Microsoft VBScript: Incompatible types' was not handled". 'Main code '-----------------------------------------------------
2
13430
by: Ken Layton | last post by:
Attempting to pass a VBScript Array of Bytes to a C# Managed COM object has resulted in some very undesirable and strange behavior. When definining a method in my C# COM class as "void Write(byte bBytes)" or "void Write(byte bBytes, int nLen)" or "int Write(byte bBytes, int nLen)"VBScript returns a "Invalid procedure call or argument" exception. However when I define the method as "int Write(byte bBytes)" it works just fine. Unfortunately...
2
9578
by: Edlueze | last post by:
Greetings: I have two functions and I would like to pass the ParamArray gathered from one function to the other function. For the purposes of this post, let's say that they are calculating averages (they're actually processing a sequence of pairs of variants and the sequence is of unknown length). I want something like these two functions:
3
3785
by: Mark | last post by:
Hi From what I understand, you can pass arrays from classic ASP to .NET using interop, but you have to change the type of the.NET parameter to object. This seems to be because classic ASP passes a variant containing an array, and interop expects a parameter of type object if you are passing a variant (you are expected to cast it to the correct type in your code). I'd like to find a way of passing arrays so that you don't need to change...
1
2141
by: Gregory Hassett | last post by:
Hello, I am calling into a legacy COM server from VB.NET. The method that I am calling expects an array. Here is the example syntax provided by the author of this COM automation object -- this syntax would (allegedly) work in VB6. The object is called RhinoScript: RhinoScript.AddLine Array(0, 0, 0), Array(10, 0, 0) Now, this syntax causes VB.NET to choke at compile-time. I have replaced it with the following (and have tried several
13
2497
by: Deano | last post by:
Apparently you can only do this with one value i.e Call MyAssetLocationZoom(Me!txtLocation, "Amend data") This runs; Public Sub MyAssetLocationZoom(ctl As Control, formName As String) On Error GoTo err_zoom strFormName = formName
0
2020
by: dwinson | last post by:
I am writing an add-in in C# for a server written in VB6. In order for my add-in to work I need to implement this method: MyMethod(string inputData) .... so my C# code looks like this: public object MyMethod(string inputData)... I wrote a test harness in VB6 to test the method. I can call the method
5
4012
by: vml | last post by:
I have a python com object which contains a method to inverse an array in vb 6 the definition of the class is : class Fop: _public_methods_ = def SqVal(self,*val): #vol=(val,val) #mat1=mat((vol)) #up=linalg.inv(mat1) return str(val)#up
0
8394
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8825
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4152
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.