1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Qualify with a Type Name error in C# code

Discussion in 'C' started by crt616, Jun 28, 2010.

  1. crt616

    crt616 New Member

    Joined:
    Jun 28, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I am new to C# and having to take sample code for encrypting ICVerify transactions for credit card processing. Below is a copy of the code but I am getting an error of
    " Error 1 Member 'ConsoleApplication1.EncryptionManager.EncryptThirdPartyMessage(string, string)' cannot be accessed with an instance reference; qualify it with a type name instead C:\Documents and Settings\relosegui\my documents\visual studio 2010\Projects\EncryptMe\EncryptMe\Encrypt.cs 45 40 EncryptMe"
    for the code highlighted in pink

    Can anyone offer assistance as to what may be my problem may be?

    Code:
    namespace ConsoleApplication1
    {
        public class EncryptionManager
        {
            [DllImport("EncryptionManager.dll")]
            public static extern string EncryptThirdPartyMessage(string filePath, string stringToEncrypt);
        }
        
        class Program
        {
        
            static void Main(string[] args)
            {
                // File name format that ICVERIFY understand for request processing
                string csFileName = "\\icver001.out";
                // Shared directory path where file is being created.
                string txtSharedDirPath = "C:\\Prod";
                string csSharedDirPath = txtSharedDirPath + csFileName;
                /*
                // Request directory path where file will be used by
                // ICVERIFY for transaction processing.
                */
                string txtReqPath = "C:\\ICVERIFY\\ICWin404\\ICPool";
                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);
     
            
            }
        }
    }
     
     
    Last edited by a moderator: Jun 29, 2010

Share This Page