Click here to Skip to main content
16,004,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Friends,

Type 'OpenNETCF.Tapi.LINEINITIALIZEEXPARAMS' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed. plz help for above error. Thanks for advance.
Posted
Comments
[no name] 8-Apr-14 8:22am    
The error message means exactly what it says. Exactly what sort of help do you expect from us based on this?
keerthana.k 9-Apr-14 2:45am    
Hi Wes Aday,
Actually I added the Tapi.dll and reference also. I created one aspx page and the code But I got above exception.So i don't know how to fix the exception.Please guide me how to solve the above issue.Thanks for reply.
keerthana.k 9-Apr-14 2:47am    
i got execption in t.Initialize(); line
Member 11449697 22-Mar-16 3:22am    
i am also getting same execption in t.Initialize();
did you find any solution?

1 solution

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OpenNETCF.Tapi;
using System.Runtime.InteropServices ;


public partial class Mobile_mSource_Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string myIMEIstring = getIMEIInfo();
        Label2.Text = "Mobile Number:" + myIMEIstring;
    }

    [DllImport("cellcore.dll")]
    internal static extern int lineGetGeneralInfo(IntPtr hLine, byte[] bCache);

    // code to get IMEI
    private string getIMEIInfo()
    {
        string IMEI;
        Tapi t = new Tapi();
        t.Initialize();
        Line _line = t.CreateLine(0, LINEMEDIAMODE.INTERACTIVEVOICE, LINECALLPRIVILEGE.MONITOR);

        byte[] buffer = new byte[512];
        //write size
        BitConverter.GetBytes(512).CopyTo(buffer, 0);

        if (lineGetGeneralInfo(_line.hLine, buffer) != 0)
        {
            throw new System.ComponentModel.Win32Exception(System.Runtime.InteropServices.Marshal.GetLastWin32Error(), "TAPI Error: " + System.Runtime.InteropServices.Marshal.GetLastWin32Error().ToString("X"));
        }

        int serialsize = BitConverter.ToInt32(buffer, 36);
        int serialoffset = BitConverter.ToInt32(buffer, 40);
        IMEI = System.Text.Encoding.Unicode.GetString(buffer, serialoffset, serialsize);
        IMEI = IMEI.Substring(0, IMEI.IndexOf(Convert.ToChar(0)));


        _line.Dispose();
        t.Shutdown();
        return (IMEI);
    }
}
 
Share this answer
 
Comments
Dipika Kakadiya 15-Mar-22 11:05am    
Hello
I get an error
Line _line = t.CreateLine(0, LINEMEDIAMODE.INTERACTIVEVOICE, LINECALLPRIVILEGE.MONITOR);

this line.
can you please help me to solve this error?
thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900