|
-
Aug 11th, 2003, 04:48 AM
#1
Thread Starter
Sleep mode
string to ref string error ??[Resolved]
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'
VB Code:
Public Shared Function FindFile(ByRef RootPath As String, ByRef FileName As String) As String
I used it like this :
Code:
MessageBox.Show(FindFileViaAPI.FileClass.FindFile("c:\\" ,"setup.exe"));
Anyone knows why ?
Last edited by Pirate; Aug 11th, 2003 at 10:09 AM.
-
Aug 11th, 2003, 06:35 AM
#2
Hyperactive Member
Have you tryed to this?:
Code:
MessageBox.Show(FindFileViaAPI.FileClass.FindFile(@"c:\\" ,"setup.exe"));
Hope thats it,
Stephan
Keep Smiling - even if its hard 
Frankie Says Relax, wossname Says Yeah!
wossname:--Currently I'm wearing a gimp suit and a parachute.
C# - Base64 Blog
-
Aug 11th, 2003, 07:24 AM
#3
have you tried adding ref, eg:
VB Code:
MessageBox.Show(FindFileViaAPI.FileClass.FindFile([COLOR=blue]ref[/color] "c:\\" ,[COLOR=blue]ref[/color] "setup.exe"));
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Aug 11th, 2003, 08:10 AM
#4
Frenzied Member
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.
-
Aug 11th, 2003, 08:19 AM
#5
Thread Starter
Sleep mode
Originally posted by Sgt-Peppa
Have you tryed to this?:
Code:
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
-
Aug 11th, 2003, 08:37 AM
#6
Frenzied Member
Try this
Code:
string _rootPath = @"C:\";
string _fileName = "setup.exe";
MessageBox.Show(FindFileViaAPI.FileClass.FindFile(ref _rootPath, ref _fileName));
-
Aug 11th, 2003, 10:07 AM
#7
Thread Starter
Sleep mode
Thanks , this works well . Do you know why ?
-
Aug 11th, 2003, 10:12 AM
#8
Frenzied Member
As to what the error said, you have to use an lvalue.
-
Aug 11th, 2003, 10:22 AM
#9
Thread Starter
Sleep mode
Cool .
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|