Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help with C# to VFP translation
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Contracts, agreements and general business
Miscellaneous
Thread ID:
01469828
Message ID:
01470271
Views:
98
Thanks for the sample Viv.

I did try that already, but here is the MAIN problem;

When I do:
xx = CREATEOBJECT("EncryptionManager")

I get the error: "External Module/OLE is not installed on this computer".
As you know, this problem is usually resolved by registering the DLL via:

>> RegSvr32 EncryptionManager.Dll

However, when I try it, the registeration FAILS and gives the error; "Could not find entery point.....".

As I mentioned below, the Developers of the DLL told me to run the following commands to REGISTER the DLL::

>>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\IcvGacUtil /i C:\ICVERIFY\ICWin403\SecurityService.dll
>>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\RegAsm C:\ICVERIFY\ICWin403\SecurityService.dll /tlb
>>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\IcvGacUtil /i C:\ICVERIFY\ICWin403\EncryptionManager.dll
>>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\RegAsm C:\ICVERIFY\ICWin403\EncryptionManager.dll /tlb

Which I did, and they all installed sucessfully. But, my CREATOBJECT statement still can not instantiate the object saying:
"The External Module/OLE is not installed on this computer".

The Developers also told me that in the VB and in C# sample code, they ADDED the DLL to their "Project". So, I went to VFP Options, and then "Controls". The problem is the EncryptionManager is not even listed there either, for me to drop it to a form.

I can't imagin VFP not having the same facilities to run this type of DLL module than there is in VB and C#.
Am I missing something ?

Thanks
Cyrus


>Sorry but my VFP is getting rustier by the day but, as stated, it should be simply a matter of a few judicious STRTOFILE() and FILETOSTR() lines. Don't know which bit you can't do but (top of my head) the encrypt would be something like:
TempPath = "C:\Test.req"
>StringToEncrypt = "SomeThing"
>STRTOFILE("",TempPath)
>xx = CREATEOBJECT("EncryptionManager")
>s = xx.EncrptThirdPartyMessage(TempPath,StringToEncrypt)
>STRTOFILE(s,TempPath)
>* Then copy to output folder
>Decrypt pretty much the same principle but maybe using ALINES() and processing each line. Someone still active in VFP should be able to straighten me out if that's wrong.......
>
>>Thanks Viv;
>>The steps you listed, is what I need the help with.
>>
>>Cyrus
>>
>>>Hi,
>>>Most of the C# code is just for creating, reading and writing to files. Should be simple in VFP:
>>>
>>>Encrypting:
>>>1. Create a file with the *.req extension in the required folder.
>>>2. Create an instance of the EncryptionManager.
>>>3. Call its EncryptThirdPartyMessage() method passing in the name of the created file (including the full path) and the string to encrypt
>>>4. Write the return value to the file.
>>>5. Copy the file to the output location.
>>>
>>>Decrypting (looks as if the input file can contain multiple strings?):
>>>1. Create a file to hold the output.
>>>2. Open the input file
>>>3. For each line in the input file
>>> (a) Call DecryptThirdPartyMessage() passing in the fullname of the input file and the line string
>>> (b) Write the returned string to the output file.....
>>>
>>>AFAICS the only reason for passing the filenames to the EncryptionManager methods is that it uses the
>>>file timestamp for something ?
>>>All the file stuff can probably be done with STRTOFILE() and FILETOSTR()
>>>
>>>
>>>
>>>
>>>>Thanks Michael; Here it is:
>>>>________________________________________________________________________________________________
>>>>TO ENCRYPT THE STRING:
>>>>
>>>>(Sample code is written in C#.Net)
>>>>
>>>>// File name format that ICVERIFY understand for request processing
>>>>string csFileName = "\\icver001.req";
>>>>// Shared directory path where file is being created.
>>>>string txtSharedDirPath = "C:\\Shared Directory";
>>>>string csSharedDirPath = txtSharedDirPath + csFileName;
>>>>/*
>>>>// Request directory path where file will be used by
>>>>// ICVERIFY for transaction processing.
>>>>*/
>>>>string txtReqPath = "C:\\Request Directory";
>>>>string csReqPreparationPath = txtReqPath + csFileName;
>>>>// Object of StreamWriter
>>>>StreamWriter objWriter = null;
>>>>// This code is creating an empty file in shared directory path
>>>>FileStream objFileStream = new FileStream(csSharedDirPath, FileMode.Create, FileAccess.Write);
>>>>objWriter = new StreamWriter(objFileStream);
>>>>/*
>>>>// To call EncryptionManager.dll to encrypt string
>>>>// EncryptionManager.dll will use the creation date of the
>>>>// file that was being created in shared directory path.
>>>>*/
>>>>string csStringToEncrypt = "Some string";
>>>>EncryptionManager objEncryptionManager = new EncryptionManager();
>>>>string csEncryptedString = objEncryptionManager.EncryptThirdPartyMessage(csSharedDirPath, csStringToEncrypt);
>>>>// To write the encrypted string in the file
>>>>objWriter.WriteLine(csEncryptedString);
>>>>if (objWriter != null)
>>>> objWriter.Close();
>>>>/*
>>>>// Once all the encrypt strings have been written in file,
>>>>// move that file into the request directory for processing.
>>>>*/
>>>>File.Move(csSharedDirPath, csReqPreparationPath);
>>>>________________________________________________________________________________________________
>>>>
>>>>TO DECRYPT THE STRING:
>>>>
>>>>(Sample code is written in C#.Net)
>>>>// File name that need to be decrypted
>>>>string csFileName = "\\icver001.ans";
>>>>// Shared directory path where decrypted file will be created.
>>>>string txtSharedDirPath = "C:\\Shared Directory";
>>>>string csSharedDirPath = txtSharedDirPath + csFileName;
>>>> /*
>>>>// Request directory path where file that needs to be
>>>>// decrypted is present.
>>>>*/
>>>>string txtReqPath = "C:\\Request Directory";
>>>>string csReqPreparationPath = txtReqPath+ csFileName;
>>>>// object of StreamWriter
>>>>StreamWriter objWriter = null;
>>>>// This code is creating an empty file in shared directory path
>>>>FileStream objFileWriteStream = new FileStream(csSharedDirPath, FileMode.Create, FileAccess.Write);
>>>>objWriter = new StreamWriter(objFileWriteStream);
>>>>StreamReader objReader = null;
>>>>FileStream objFileReadStream = new FileStream(csReqPreparationPath, FileMode.Open, FileAccess.Read);
>>>>objReader = new StreamReader(objFileReadStream);
>>>>/*
>>>>// To call EncryptionManager.dll to decrypt string
>>>>// EncryptionManager.dll will use the creation date of the
>>>>// file that was being created in Request directory path.
>>>> */
>>>>EncryptionManager objEncryptionManager = new EncryptionManager();
>>>>string strDecString = "";
>>>>string strEncString = "";
>>>>while (((strEncString = objReader.ReadLine()) != null))
>>>>{
>>>>strDecString = objEncryptionManager.DecryptThirdPartyMessage(csReqPreparationPath, strEncString);
>>>>objWriter.WriteLine(strDecString);
>>>>}
>>>>if (objReader != null)
>>>>objReader.Close();
>>>>if (objWriter != null)
>>>>objWriter.Close();
>>>>________________________________________________________________________________________________
>>>>
>>>>And they had me run the following to register the DLLs in Windows Command Prompt:
>>>>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\IcvGacUtil /i C:\ICVERIFY\ICWin403\SecurityService.dll
>>>>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\RegAsm C:\ICVERIFY\ICWin403\SecurityService.dll /tlb
>>>>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\IcvGacUtil /i C:\ICVERIFY\ICWin403\EncryptionManager.dll
>>>>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\RegAsm C:\ICVERIFY\ICWin403\EncryptionManager.dll /tlb
>>>>________________________________________________________________________________________________
>>>>
>>>>Pease let me know the cost, so you can just put it on my card.
>>>>Thanks
>>>>Cyrus
>>>>
>>>>
>>>>>>I am trying to use an External DLL (supplied by a Payment Transaction company ICVerify) to
>>>>>>
>>>>>>a) convert a String Variable into an encrypted file, and then
>>>>>>b) Decrypt the File into a String variable.
>>>>>>
>>>>>>They don't have a VFP sample code, but they have supplied Sample Code in C#.
>>>>>>It is about 5 to 10 commands. I need to have the C# code translated into VFP code and then some help in getting it to run.
>>>>>>
>>>>>>Please let me know asap.
>>>>>
>>>>>Could you simply paste the code in here?
Cyrus Nima
-------------------
cyrusnima@gmail.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform