Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 131,651 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 3,558 people online right now. Registration is fast and FREE... Join Now!




InteropServices Exception

 
Reply to this topicStart new topic

InteropServices Exception

AnujaG
post 4 Oct, 2008 - 12:48 AM
Post #1


New D.I.C Head

*
Joined: 4 Oct, 2008
Posts: 1

CODE


sector = Convert.ToInt32(j / 8192);
                for (int i = 0; i <= sector + 1; i++)
                //for (int i = 0; i <= 5; i++)
                {
                    //if (!axMSComm1.PortOpen)
                    if (!axNETComm1.PortOpen)
                    {
                        //axMSComm1.PortOpen = true;
                        axNETComm1.PortOpen = true;
                    }
                    //axMSComm1.InBufferCount = 0;
                    axNETComm1.InBufferCount = 0;
                    strPmtk = "PMTK182,7," + i * 2000 + ",2000";
                    strChksum = getCheckSum(strPmtk);
                    pmtkstr2 = "$" + strPmtk + "*" + strChksum;
                    //axMSComm1.Output = pmtkstr2;
                    String Buffer = pmtkstr2 + "\r\n";
                    Object oBuffer = (object)Buffer;
                    //axNETComm1.set_Settings(ref oBuffer);
                  
                    axNETComm1.set_Output(ref oBuffer);
                
                    //axMSComm1.Output = pmtkstr2 + "\r\n";
                                
                    System.Threading.Thread.Sleep(1000);

                    string pmtk = "";
                    string Str = "";
                    //if (axMSComm1.InBufferCount > 0)
                    if (axNETComm1.InBufferCount > 0)
                    {
                       // Str = axMSComm1.Input.ToString();
                        Str = axNETComm1.InputData.ToString();
                    }
                    else
                    {
                                              
                        MessageBox.Show("null");  
                    }



The loop goes in the else part and gives a "null" mesaage after it loops through 7 sectors. the mscomm1.output throws an exception System.Runtime.InteropServices.COMException
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/20/08 06:25AM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month