Hi
I need to be able to return a string from a VB6 method:
Public Sub GetMessageAsPar ameter(ByRef message As String)
message = "GetMessageAsPa rameter worked!"
End Sub
which is implemented inside an ActiveX DLL. I need to do this using late
binding so I am trying to do it with code like this:
object[] parameters = new object[1];
ParameterModifi er parameterModifi ers = new ParameterModifi er(1);
// Allocate some space for the parameter
parameters[0] = new string(' ', 100);
parameterModifi ers[0] = true;
ParameterModifi er[] parameterModifi er = { parameterModifi ers };
comType.InvokeM ember("GetMessa geAsParameter",
BindingFlags.In vokeMethod, null, comObject, parameters, parameterModifi er,
null, null);
Console.WriteLi ne(String.Forma t("\nGetMessage AsParameter:
Message={0}", parameters[0].ToString()));
The problem is that I never get anything coming back. I don't get any
TargetInvocatio nExceptions either. I've tried all the different options of
ByVal and ByRef without success.
Please could anyone advise.
Thanks
Marek 2 2175
Hi
I've worked it out:
parameters[0] = new StringBuilder(1 00).ToString();
Thanks.
Marek
"Marek" wrote:
Hi
I need to be able to return a string from a VB6 method:
Public Sub GetMessageAsPar ameter(ByRef message As String)
message = "GetMessageAsPa rameter worked!"
End Sub
which is implemented inside an ActiveX DLL. I need to do this using late
binding so I am trying to do it with code like this:
object[] parameters = new object[1];
ParameterModifi er parameterModifi ers = new ParameterModifi er(1);
// Allocate some space for the parameter
parameters[0] = new string(' ', 100);
parameterModifi ers[0] = true;
ParameterModifi er[] parameterModifi er = { parameterModifi ers };
comType.InvokeM ember("GetMessa geAsParameter",
BindingFlags.In vokeMethod, null, comObject, parameters, parameterModifi er,
null, null);
Console.WriteLi ne(String.Forma t("\nGetMessage AsParameter:
Message={0}", parameters[0].ToString()));
The problem is that I never get anything coming back. I don't get any
TargetInvocatio nExceptions either. I've tried all the different options of
ByVal and ByRef without success.
Please could anyone advise.
Thanks
Marek
Not sure what happened with the previous reply (appears blank), but the fix
for my problem was:
parameters[0] = new StringBuilder(1 00).ToString();
"Marek" wrote:
Hi
I need to be able to return a string from a VB6 method:
Public Sub GetMessageAsPar ameter(ByRef message As String)
message = "GetMessageAsPa rameter worked!"
End Sub
which is implemented inside an ActiveX DLL. I need to do this using late
binding so I am trying to do it with code like this:
object[] parameters = new object[1];
ParameterModifi er parameterModifi ers = new ParameterModifi er(1);
// Allocate some space for the parameter
parameters[0] = new string(' ', 100);
parameterModifi ers[0] = true;
ParameterModifi er[] parameterModifi er = { parameterModifi ers };
comType.InvokeM ember("GetMessa geAsParameter",
BindingFlags.In vokeMethod, null, comObject, parameters, parameterModifi er,
null, null);
Console.WriteLi ne(String.Forma t("\nGetMessage AsParameter:
Message={0}", parameters[0].ToString()));
The problem is that I never get anything coming back. I don't get any
TargetInvocatio nExceptions either. I've tried all the different options of
ByVal and ByRef without success.
Please could anyone advise.
Thanks
Marek
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: mike |
last post by:
hello,
Using Type.InvokeMember to call a method of a
class,Which
method has byref parameter,It seems that there is
no way to return the changed value of that byref
parameter by the method of the class.
Who can save me?
Thanks a lot!
|
by: David |
last post by:
Hi, I have a program in which I used invokemember to late bind to a
component.
In my code I use:
SetupInfo setup;
Object objTem = callLateBinding ("BackOfficeServer.BackOffice",
"getSetupByDescription", parameter);
setup = (Transaction.SetupInfo)objTem;
|
by: A.M |
last post by:
Hi,
Are string parameters in functions by refrence or by value ?
Thanks,
Ali
|
by: Rein Petersen |
last post by:
Hi All,
I'm invoking Type.InvokeMember() on a COM class (via COMInterop) through
a generalized interface. However, each specialized instance (of the
COMInterop generic interface) requires slightly different arguments for
which I dynamically create the object arguments and it all works nicely.
Problem is, in some instances, I have methods which require certain
arguments to be referenced (ref string x,...etc). I'm not sure how I can...
|
by: Mike Moore |
last post by:
does anyone have an example of how to get the connection string object
converted to a string variable type in order for me to call a function?
| |
by: =?Utf-8?B?UGF1bA==?= |
last post by:
Hi I have the method below that returns a bool, true or false depending
on if the conversion to date tiem works. It takes a string input. I am
only returning the bool but would also like to return the string message
ex.message, just wondering how to do this since I think you can only return
one thing with the function. Thanks.
public bool checkdate(String s_date)
{
b_convert = true ;
DateTime dt_temp1 =...
|
by: adh |
last post by:
In c# you can return a String() but in VB.NET2005 it does not work (the
webservice test sends to the error page).
See MS AJAX Controls Toolkit.Autocomplete which demands a String()
reply.
I prefer doing it in VB but how?
Thanks, adh
*** Sent via Developersdex http://www.developersdex.com ***
|
by: Thomas Lenz |
last post by:
Please consider the following code snippet:
string myfunction()
{ ostringstream oss;
oss << "junk";
// do something more with oss; I can't make it const...
return oss.str();
}
Is the returned string object still valid after myfunction() has returned? I
|
by: GaryDean |
last post by:
The following command...
string DebugString =
System.Web.HttpContext.Current.Server.MapPath("App_Themes");
is executed from my ThemeManager.cs class in my App_code directory
It returns...
"c:\\inetpub\\wwwroot\\TaxBusiness\\AnonymousAccess\\App_Themes"
The folders in my website project are...
Admin
|
by: raghunadhs |
last post by:
Hi All,
i want to create a ATL com Object, and add this object as a reference to my VB application.
my ATL com should contain 3 parametes. two are input parameters of type string, and an out put parameter of type long.
when i try to pass strings as parameters, the .lib file is being crated and i am able to add it as a reference to my VB application also. but when i try to run the VB application, an error is coming like "Memory out of...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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();...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |