Hello Chris, Robert,
Thanks for the explanation and the workarounds. However, adding the code like this (with or without semicolon) :
cConn:=CurDrive() + ":" + CurDir()
[DllImport("ace32.dll", CharSet := CharSet.Ansi)];
If lRemoteADS
ulRetVal:=AdsConnect60(cConn ,XSharp.ADS.ACE.ADS_REMOTE_SERVER, "adssys", Null, (Dword)XSharp.ADS.ACE.ADS_DEFAULT, hConn)
gives these 4 errors on the same line (the one in bold, with ADSConnect60 in it):
Error XS9002 Parser: mismatched input '(' expecting EOS (2X)
Error XS9002 Parser: unexpected CRLF, are you missing a token ?
Error XS9002 Parser: unexpected input 'CharSet.Ansi)'
Then I thought I should probably move it at the start of the containing method like with [System.Diagnostics.DebuggerHidden()] but when I do that it gives:
Error XS0601 The DllImport attribute must be specified on a method marked 'static' and 'extern'
The method is currently a Public Virtual Method and although I usually don't have specific reasons to make a method anything special (like in VO where a METHOD is simply a METHOD everywhere in my programs) some method types in X#/Vulcan have been chosen after some of the other ways failed. Which proves because when I make the method STATIC EXTERN as the error suggests I should do I get XS0179 'Method' cannot be extern and declare a body.
In short, I don't want to change my method type from 'working' to 'possible not working'.
I also tried including ADS.PRG which gives over 300 errors in the #region Constructor. When I remove the entire region only the above errors remain. Also I noticed that in ADS.PRG
PUBLIC STATIC METHOD AdsConnect60(strServerPath as string , usServerTypes as WORD, strUserName as string , strPassword as string , ulOptions as DWORD, phConnect out IntPtr ) as DWORD
is outcommented under // Unused methods. Is that correct?
Is it probably better to wait until the missing parts are added without the need to change my code further? Or would you like me to test the actual program with additional info how to deal with these new errors?
Dick
dbServer access in Bandol RC 2 & some other issues
dbServer access in Bandol RC 2 & some other issues
Dick,
You need to put the code that I showed not inside your current code but as a separate function in your source.
And I did not mean that you should include ADS.PRG in your code. This was for reference only.
And indeed the function is commented out, that is why it does not work .
Robert
You need to put the code that I showed not inside your current code but as a separate function in your source.
And I did not mean that you should include ADS.PRG in your code. This was for reference only.
And indeed the function is commented out, that is why it does not work .
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
dbServer access in Bandol RC 2 & some other issues
Hello RobertYou need to put the code that I showed not inside your current code but as a separate function in your source.
Sorry, I still don't know how. If I just add a new program and tried a couple of combination of how to add the code which shouls solve the ADSConnect error.
You can skip to 4 (which compiles the added program but still doesn't solve the ADSConnect60 error....)
1 (with or without semicolon)
[DllImport("ace32.dll", CharSet := CharSet.Ansi)];
-->Error XS9002 Parser: unexpected End of Statement, are you missing a token
2
Begin Namespace NameSpaceOfMainProgram
Function something As Void
[DllImport("ace32.dll", CharSet := CharSet.Ansi)]
Return Nil
End Namespace
-->Error XS9002 Parser: unexpected CRLF, are you missing a token ? (on [DLL import line);
3 Same but then with a ; ([DllImport("ace32.dll", CharSet := CharSet.Ansi)]; )
-->Error XS9002 Parser: unexpected input '[DllImport("ace32.dll", CharSet := CharSet.Ansi)];CRLFReturn'
4
Begin Namespace CheckMail
[DllImport("ace32.dll", CharSet := CharSet.Ansi)];
Function something As Void
Return Nil
End Namespace
+ adding every #using I could find:
then the added program compiles but I still get:
Error XS0103 The name 'AdsConnect60' does not exist in the current context iConnectMailReader
Note: In C# I can solve errors of missing usings with Ctrl + (Quick Actions and Refactorings). I guess that's not easy to implement in X#? What would be the best way to find which #using is required for a keyword? Without all my #usings DLLImport fails (errors mentions DLLImportAttribute and CharSet as missing if I ommit the #usings) but the help does not tell me which #using I would need.
Dick
dbServer access in Bandol RC 2 & some other issues
Dick,
- create a new, empty file
- type the following code
And then in your code you can call AdsConnect60()
Explanation:
- The Function statement defines the parameters and return type. There is no body because this function is 'External'
- The [DllImport...] attribute tells the .Net runtime that this function is in an external DLL "ace32.dll" and that the string parameters should be converted to Ansi
Note:
You could also use the _DLL FUNCTION syntax but then it is more difficult to tell the .Net runtime how to handle strings.
Robert
- create a new, empty file
- type the following code
Code: Select all
USING System
USING System.Runtime.InteropServices
DllImport("ace32.dll", CharSet := CharSet.Ansi)];
FUNCTION AdsConnect60(pucServerPath AS STRING , usServerTypes AS WORD, ;
pucUserName AS STRING , pucPassword AS STRING , ulOptions AS DWORD, phConnect OUT IntPtr ) AS DWORD
Explanation:
- The Function statement defines the parameters and return type. There is no body because this function is 'External'
- The [DllImport...] attribute tells the .Net runtime that this function is in an external DLL "ace32.dll" and that the string parameters should be converted to Ansi
Note:
You could also use the _DLL FUNCTION syntax but then it is more difficult to tell the .Net runtime how to handle strings.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
dbServer access in Bandol RC 2 & some other issues
Hello Robert,
I've done exactly what you wrote, pasted your code instead of the default code found in the new empty code file and this is what get on the DLLImport line:
Error XS9002 Parser: unexpected input 'DllImport'
Documentation for Error XS9002 is limited to:
Parser: {0}
Dick
I've done exactly what you wrote, pasted your code instead of the default code found in the new empty code file and this is what get on the DLLImport line:
Error XS9002 Parser: unexpected input 'DllImport'
Documentation for Error XS9002 is limited to:
Parser: {0}
Dick
dbServer access in Bandol RC 2 & some other issues
Dick,
I think the left most [ is missing. It should be:
Jamal
I think the left most [ is missing. It should be:
Code: Select all
[DllImport("ace32.dll", CharSet := CharSet.Ansi)];
dbServer access in Bandol RC 2 & some other issues
Hello Jamal,I think the left most [ is missing. It should be:
Ahh.. You are right, thanks. I just copied and pasted it. Should have seen this myself
I will have to add AdsDisconnect as well but then it may work - let you all know.
Dick
dbServer access in Bandol RC 2 & some other issues
Not sure why this is posted in the Welcome forum. I did select Product from the subscriber forum. I'll continue it there.
Dick
Dick
dbServer access in Bandol RC 2 & some other issues
Dick,
I moved the message to the product forum
Robert
I moved the message to the product forum
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu