Click to See Complete Forum and Search --> : string to ref string error ??[Resolved]
Pirate
Aug 11th, 2003, 04:48 AM
This is weird . Below, the method signature is marked as ByRef . I exported this class to dll file . It works fine in VB. In C# , it gives me two strange errors .They say : Argument '1': cannot convert from 'string' to 'ref string'
and
Argument '2': cannot convert from 'string' to 'ref string'
Public Shared Function FindFile(ByRef RootPath As String, ByRef FileName As String) As String
I used it like this :
MessageBox.Show(FindFileViaAPI.FileClass.FindFile("c:\\" ,"setup.exe"));
Anyone knows why ?
Sgt-Peppa
Aug 11th, 2003, 06:35 AM
Have you tryed to this?:
MessageBox.Show(FindFileViaAPI.FileClass.FindFile(@"c:\\" ,"setup.exe"));
Hope thats it,
Stephan
dynamic_sysop
Aug 11th, 2003, 07:24 AM
have you tried adding ref, eg:
MessageBox.Show(FindFileViaAPI.FileClass.FindFile(ref "c:\\" ,ref "setup.exe"));
DevGrp
Aug 11th, 2003, 08:10 AM
What dynamic_sysop said. See, in C# you have to use the ref keyword when passing in a value type variable by reference. Its a little different with reference types.
Pirate
Aug 11th, 2003, 08:19 AM
Originally posted by Sgt-Peppa
Have you tryed to this?:
MessageBox.Show(FindFileViaAPI.FileClass.FindFile(@"c:\\" ,"setup.exe"));
Stephan
The same error arised again .
and
When I tried what dynamic_sysop said , it gives this error :
A ref or out argument must be an lvalue
:confused:
DevGrp
Aug 11th, 2003, 08:37 AM
Try this
string _rootPath = @"C:\";
string _fileName = "setup.exe";
MessageBox.Show(FindFileViaAPI.FileClass.FindFile(ref _rootPath, ref _fileName));
Pirate
Aug 11th, 2003, 10:07 AM
Thanks , this works well . Do you know why ?
DevGrp
Aug 11th, 2003, 10:12 AM
As to what the error said, you have to use an lvalue.
Pirate
Aug 11th, 2003, 10:22 AM
Cool .:)
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.