Search code examples
c#.netcrystal-reports

using mscomm32.ocx in crystalreports application


I'm using vs 2010 with sap crystal reports for vs 2010. when I'm using Microsoft communication control (MSCOMM32) to communicate with my USB Modem in crystal repororts application and running the application, I'm getting this error. Could not load file or assembly 'Interop.MSCommLib, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format. while when I romove MSCOMM32 control from my crystal report application it works/runs fine. I'm not getting any error using MSCOMM32 Control if I don't use crystal report with my C#.Net application. Can anyone plz solve this problem??


Solution

  • why to use such an old control like Mscomm32 for sending sms. try using Serial port instead. hear is the code example for using serial port instead of MSCOMM32

    private void btnsend_Click(object sender, EventArgs e)
        {
            using (var sp = new SerialPort("COM4"))
            {
                sp.Open();
                sp.WriteLine("AT" + Environment.NewLine);
                sp.WriteLine("AT+CMGF=1" + Environment.NewLine);
                sp.WriteLine("AT+CMGS=\"" + "phone no" + "\"" + Environment.NewLine);
                sp.WriteLine("your text message" + (char)26);
            }
        }