473,396 Members | 2,158 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,396 software developers and data experts.

How to use a DLL which has complex optional parameters

Hello

I'm trying to use this OLE DLL interface in a C# program:
Expand|Select|Wrap|Line Numbers
  1.  [id(0x60030016), helpstring("Adds a new Data Value to the recordset"), helpcontext(0x00000c1d)]
  2. HRESULT Add(
  3.                 [in, out] BSTR* Tagname, 
  4.                 [in, out] DATE* TimeStamp, 
  5.                 [in, out, optional, defaultvalue(<unprintable IDispatch*>)] _DataValue** InValue, 
  6.                 [out, retval] _DataValue** );
  7.  
Here is the C# code

Expand|Select|Wrap|Line Numbers
  1. iHistorian_SDK.DataRecordset MyRecordsetD;
  2. MyRecordsetD = MyData.NewRecordset();
  3. iHistorian_SDK.DataValue MyValue;
  4. string TestTagD = "TestTag";
  5. DateTime TestDate = DateTime.Parse("6/10/2010 15:30");
  6. MyRecordsetD.Add(ref TestTagD, ref TestDate);
  7.  
The last line generates an error "No overload for method 'Add' takes '2' arguments"

I've scoured the internet and have tried every filling in the 3rd parameteer with every permutation of System.Reflection.Missing.Value, [DllImport("")], etc, etc, imaginable.

DataValue does not have a constructor. The only way to instantiate a DataValue is by using DataRecordset.Add.

Any ideas?
Jun 16 '10 #1
2 2478
GaryTexmo
1,501 Expert 1GB
I've never encountered this before, but two thoughts occur to me...

1. What does intellisense say you get for overloads on the Add method?

2. Have you tried calling with 3 parameters, but just passing null as the 3rd parameter? What about an IDispatch* object?

I'm grasping at straws here, I don't know this system but I figured I'd make a comment in an attempt to be helpful. If anything, hopefully I'll jog your brain, or someone else will have some ideas.
Jun 16 '10 #2
Thanks for the reply Gary. I had tried every permutation I could think of, of 2 parameters, 3 parameters, dummy 3rd parameter, IDispatch* object, etc, etc. Finally did find the answer though. Apparently this was a shortcomming of C# as version 4 now supports optional parameters and defaults. So, the solution was simply to upgrade to Developer's studio 2010. (I had been using MSDS 2005). Thanks again for your reply.

Gary
Jun 17 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Rane Bowen | last post by:
Hi, I am using python with a makepy generated wrapper on a COM application. One of this object's methods has 3 parameters, two of which are optional. If I call the method with just the...
2
by: Frank Rizzo | last post by:
Does c# support optional parameters in function declarations? Does it support assignment of default values to arguments, in particular optional parameters? If so, can someone point me to or...
0
by: lakshmi | last post by:
include the following lines of code: using System.Runtime.InteropServices; prefix the optional argument with This takes care if an optional parameter is not supplied by a VB script client....
16
by: ad | last post by:
Does C#2.0 support optional parameters like VB.NET: Function MyFunction(Optional ByVal isCenter As Boolean = False)
3
by: guy | last post by:
found this oddity- copying a vb6 function with optional parameters and pasting it into a vb2003 class, for conversion purposes, it all works fine except that the collapsing "-" on the LHS goes...
5
by: Water Cooler v2 | last post by:
So you have optional parameters for functions/methods in Visual Basic ..NET, but not in C#?
14
by: cody | last post by:
I got a similar idea a couple of months ago, but now this one will require no change to the clr, is relatively easy to implement and would be a great addition to C# 3.0 :) so here we go.. To...
12
by: pamelafluente | last post by:
Hi guys, In the past I have used several time optional parameters in my function. But Now I am more inclined to think that they are more dangerous than useful, and probably better to be...
7
by: Sam Shrefler | last post by:
I'm working on creating a WebService / WebMethod to receive a record in real time from another system. The record contains about 20 fields. 10 of which aren't required. I was planning on just...
1
by: peridian | last post by:
This is more of a general question, but I didn't know where to post it. Since Java is an example of a language which does this, I thought here would work. Coming from a C++ background, having...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.