473,761 Members | 9,477 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cannot convert from 'string' to 'ref string'

I have an activeX dll, I am calling one function from that
dll. I am using C# as coding language. I am getting
following error.
cannot convert from 'string' to 'ref string'
How do I call this function ?.

My statement is like this
CustomOutVal = CustObj.Authent icate(txtUserNa me.Text,
pass , Domain );

Regards,
Kishor
Nov 16 '05 #1
4 9041
hi
try passing the strings as ref to the function

check this article
http://www.codeproject.com/dotnet/cominterop.asp

regards
ansil

"kishor" wrote:
I have an activeX dll, I am calling one function from that
dll. I am using C# as coding language. I am getting
following error.
cannot convert from 'string' to 'ref string'
How do I call this function ?.

My statement is like this
CustomOutVal = CustObj.Authent icate(txtUserNa me.Text,
pass , Domain );

Regards,
Kishor

Nov 16 '05 #2
kishor <ki****@discuss ions.microsoft. com> wrote:
I have an activeX dll, I am calling one function from that
dll. I am using C# as coding language. I am getting
following error.
cannot convert from 'string' to 'ref string'
How do I call this function ?.


By specifiying the parameter as "ref" as well.

See http://www.pobox.com/~skeet/csharp/parameters.html

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3
Which of the parameters is supposed to be passed by ref?? If it is the first
parameter (txtUserName.Te xt) then you will need to create another string
variable, set it = to txtUserName.tex t and pass that into the call. The
reason for this is that properties cannot be used as reference parameters..

To top this off, when calling a method that has a ref parameter, specify the
ref keyword..

an example would be (if the first parameter is the ref parameter):
string tempUserName = txtUserName.Tex t;
CustomOutVal = CustObj.Authent icate(ref tmpUserName,
pass , Domain );

Hope this helps

Eddie de Bear

"kishor" wrote:
I have an activeX dll, I am calling one function from that
dll. I am using C# as coding language. I am getting
following error.
cannot convert from 'string' to 'ref string'
How do I call this function ?.

My statement is like this
CustomOutVal = CustObj.Authent icate(txtUserNa me.Text,
pass , Domain );

Regards,
Kishor

Nov 16 '05 #4
Thanks,
problem solved

Kishor

"Eddie de Bear" wrote:
Which of the parameters is supposed to be passed by ref?? If it is the first
parameter (txtUserName.Te xt) then you will need to create another string
variable, set it = to txtUserName.tex t and pass that into the call. The
reason for this is that properties cannot be used as reference parameters..

To top this off, when calling a method that has a ref parameter, specify the
ref keyword..

an example would be (if the first parameter is the ref parameter):
string tempUserName = txtUserName.Tex t;
CustomOutVal = CustObj.Authent icate(ref tmpUserName,
pass , Domain );

Hope this helps

Eddie de Bear

"kishor" wrote:
I have an activeX dll, I am calling one function from that
dll. I am using C# as coding language. I am getting
following error.
cannot convert from 'string' to 'ref string'
How do I call this function ?.

My statement is like this
CustomOutVal = CustObj.Authent icate(txtUserNa me.Text,
pass , Domain );

Regards,
Kishor

Nov 16 '05 #5

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

Similar topics

15
10693
by: Wilfried Mestdagh | last post by:
Hello, probably a beginners question :) I have this code sample in VB: if (objResults.Item(1).etc Translate this into C# if (objResults.etc But compiler complains about the index '1' with: cannot convert from int to
8
2220
by: Gee | last post by:
I get the above error with this code and I can't figure out why? Any ideas please? See code below - the actual error is included in the code: public struct NETRESOURCE { public Int32 dwScope ; public Int32 dwType; public Int32 dwDisplayType;
3
3431
by: Chris | last post by:
Hi, I have the following procedure below: I am getting 2 errors on compile: Argument '2': cannot convert from 'System.Data.SqlClient.SqlDataReader' to 'ref System.Data.SqlClient.SqlDataReader' Argument '3': cannot convert from 'System.Text.StringBuilder' to 'ref System.Text.StringBuilder'
2
3683
by: Sanjay Tibrewal | last post by:
Hello there, I have some code in a VB library dll whose signature is as // VB private library code Public Sub ExecuteNonQuery(ByVal sConn As String, _ ByRef oCmd As SqlClient.SqlCommand) I create another project in C# and include the library locally. I use the following code to
7
1749
by: Mike Howard | last post by:
I'm trying to convert the following (simplified) VB.Net code to C#, that makes use of some externally developed COM code written in VB6. VB.Net Code Sub Main() Dim oAPP As Object Dim oApp2 As APP2.Class Dim user As String
1
5998
by: ivanet | last post by:
Hello everyone, I am trying to use the following Schema but I get the error "src- resolve: Cannot resolve the name 'ValuesList' to a(n) 'element declaration' component." at line 144. I have been reading http://www.w3.org/TR/xmlschema-1/#src-resolve, but I don't get what is wrong. Can anyone give me a hint? Thanks in advance.
7
16708
by: groups | last post by:
This is my first foray into writing a generic method and maybe I've bitten off more than I can chew. My intent is to have a generic method that accepts a value name and that value will be returned from the source. My first attempt was as follows; (please ignore that error handling is not present in this example) public T GetValue<T(string objName) { T results;
2
18149
by: mlb5000 | last post by:
I seem to be having issues validating an XML document using my schema. Both are below: The Schema: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Receivers" > <xs:complexType> <xs:choice maxOccurs="unbounded"> <xs:element ref="MulticastReceiver"/>
4
5327
by: Pramod | last post by:
Hi. I have a C++ method which accepts - byte* - and I am calling this method from a C# application. I have created a byte to pass by ref. This is how I call the C++ method: Method(ref byteArray); However, this results in following error: Cannot convert 'ref byte' to 'ref byte'
0
9376
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10136
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
9923
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
9811
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 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...
0
8813
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, 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...
1
7358
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 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...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3509
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
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.