473,386 Members | 1,823 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,386 software developers and data experts.

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.Authenticate(txtUserName.Text,
pass , Domain );

Regards,
Kishor
Nov 16 '05 #1
4 9012
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.Authenticate(txtUserName.Text,
pass , Domain );

Regards,
Kishor

Nov 16 '05 #2
kishor <ki****@discussions.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.com>
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.Text) then you will need to create another string
variable, set it = to txtUserName.text 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.Text;
CustomOutVal = CustObj.Authenticate(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.Authenticate(txtUserName.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.Text) then you will need to create another string
variable, set it = to txtUserName.text 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.Text;
CustomOutVal = CustObj.Authenticate(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.Authenticate(txtUserName.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
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'...
8
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...
3
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...
2
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...
7
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...
1
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...
7
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...
2
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...
4
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
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...
0
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,...

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.