none
Old perl code in .NET RRS feed

  • Question

  • We're going to be programming our tools in C# in a few months, but will our old perl modules still run? They were written on a unix machine. Thanks!
    Thursday, October 9, 2008 4:19 PM

Answers

  •  

    Hello,

            You know if your old Perl modules could be in the format of Windows DLL files (Binary), we could call the methods in the module from Visual C#, by the help of P/Invoke.   Copy the module files to the same folder of your application files, then .NET P/Invoke will find the DLL file automatically.  And we could use some codes like the following to call the internal method.   Of course I only give the sample, you could so some modification here. 

    ---------------------------------------------------------------
            [DllImport("PerlModule.dll")]

                    static extern int Calculate(int a, int b);

     

            public Form1()

            {

                InitializeComponent();

                MessageBox.Show(Calculate(1, 1).ToString());

            }


    ---------------------------------------------------------------
             
             Besides, here are some good articles on how to use P/Invoke:
            
    http://msdn.microsoft.com/en-us/library/aa446536.aspx
             http://msdn.microsoft.com/en-us/library/aa719104(VS.71).aspx
             http://msdn.microsoft.com/en-us/magazine/cc164123.aspx

             Thanks,

    Best Regards,

    Lingzhi

    Please remember to mark the replies as answers if they help and unmark them if they provide no help. http://forums.msdn.microsoft.com/en-US/csharpide/thread/8e9ed0d7-11ff-402a-8489-9b5f05eeb706 http://forums.msdn.microsoft.com/en-US/vssetup/thread/60424309-bd78-4ca2-b618-03c4a16123b6
    Monday, October 13, 2008 7:02 AM
    Moderator