|
I have a class that I need to convert to a byte array for a Windows Mobile device. The byte array is sent using ssl to a server, which needs to rebuild the class. I have used BinaryFormatter on a PC client that worked great. However I can't use that with the compact framework. This is the code I am currently trying to use but its giving me the error message "Type 'PackageTrans' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed.".
public byte[] ClassToBytearray(object obj)
{
int Length = Marshal.SizeOf(obj); <----------This is where I get the error.
byte[] bytearray = new byte[Length];
IntPtr ptr = Marshal.AllocHGlobal(Length);
Marshal.StructureToPtr(obj, ptr, false);
Marshal.Copy(ptr, bytearray, 0, Length);
Marshal.FreeHGlobal(ptr);
return bytearray;
}
This is my first time using Marshal. Why wouldn't a meaningful size or offset be computed? What is it that I am missing? Is there a different way I should be doing this? Any and all help would be greatly appreciated.
Thanks
-Kio
modified on Friday, June 11, 2010 1:25 AM
|
|
|
|
|
Look into serialization, there are many options -> Binary, xml, soap, etc.
|
|
|
|
|
hello
How did you manage?
|
|
|
|
|
Hi Friends,
I am developing a Windows Mobile application using 6.0 professional SDK.
Here I am consuming a web service which is hosted on HTTPS.
I am able to add the web reference successfully but when I call a method of the service using proxy it throws following exception.
"Could not establish trust relationship with remote server."
The same scenario works fine if I test it with a desktop windows application. I am able to call the method successfully and I receive the response too, but I dont know why it is not working with Windows Mobile.
I am able to browse the websites from the mobile browser so there is no issue about the connection.
Please help me soon friends I m running out of time...I have search all over the world during last 2 days but could not find any satisfactory and working solution.
Thank you all in advance.
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
The first thing I would check is the date and time on your Windows Phone. It it is wrong then SSL authentication will fail.
|
|
|
|
|
Hi Joel,
Thanks for the reply.
I tried the tip you mentioned. I am currently running the application on device emulators.
I changed the date time information of the emulator to my system date time but it didn't work.
The web service I m consuming is in different timezone, and I tried to change the emulator datetime information to that timezone too, but that also didn't help me.
I event asked the service providers but according to them there is nothing changed from their side except the service url which I am currently using.
If I refer the same service url in a windows desktop application, everything works fine.
I am really stuck. Please help me.
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
Dude! I tried this (setting the correct date/time) out of desperation after continually having a "Could not establish trust relationship with remote server" error message and it flippin' worked. Thanks for the tip--why can't these error messages give a little more information????
|
|
|
|
|
Hi friends,
Finally I found the solution of this problem.
I had to create a class which implemented ICertificatePolicy interface as following.
public class AlwaysTrustedCertificatePolicy : ICertificatePolicy
{
#region ICertificatePolicy Members
public bool CheckValidationResult(ServicePoint srvPoint,
System.Security.Cryptography.X509Certificates.X509Certificate certificate,
WebRequest request,
int certificateProblem)
{
return true;
}
#endregion
}
And before calling the first ever method of service I created an instance of this class and assign it to "CertificatePolicy" of "ServicePointManager" class.
ICertificatePolicy certificatePolicy = new new AlwaysTrustedCertificatePolicy();
ServicePointManager.CertificatePolicy = certificatePolicy;
var serviceClient = new ServiceClient();
serviceClient.Login(username, password);
This worked for me very well... but this is I guess work around not the proper solution.
If any body finds the solution please post.
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
dear experts
i have recently seen some projects in web controlling electrical devices form s60 mobiles and the program written here in s60 mobile is python now i want to write my own code .pls any body suggest me which book to read ,web add for reference thanks in advance.
|
|
|
|
|
Hi,
I am using a Windows Mobile 6.1
I want to programatically know if currently the phone is connected to the internet through WiFi or GPRS or USB ?
How can I achieve this ?
Preferably in Managed code.
|
|
|
|
|
f9로 중단점을 설정하였습니다.
Debug mode was exited automatically when i want to use debug mode by press F5 key.
and i realize there is error when internet explore windows is running.
so i want to know how am i fix this?
(These day , i close all of internet explore windows and run debug mode)
hi
My english is a little.
anyway, nice to meet you~~
and give me your advice anytime~
|
|
|
|
|
Hi all,
i m using Nokia Mobile Phone ,i want to develop an application,that is able to access all things Inside of Nokia Phone, like Contacts,Messages,Task,Calendat,Notes,Files etc.
pleease can anybody help me and provide me guidance from where i can start.
please help me for this thanks in advance.
i m waiting for ur valuable suggestions.
|
|
|
|
|
Le@rner wrote: i m waiting for ur valuable suggestions.
I would suggest you go to the Nokia web site and research their SDK/API offerings.
It's time for a new signature.
|
|
|
|
|
hello guys....im new in mobile development. If I want to develop database apps for windows mobile, then what should i need to install, sql server or sql server ce?? thanx for ur help
|
|
|
|
|
Hi Muzammil,
see this article for the same. Link[^]
Pavan Pareta
|
|
|
|
|
Hi all,
I want to send sms from my blackberry pone with my PC,
i have already done this for other Simple GSM Based mobile phone ,here i m using AT commands and send sms from PC with My GSM Based Mobile phone.
but this not working for blackberry.
can u please tell me how can i do this?
thanks in advance.
modified on Thursday, May 13, 2010 7:25 AM
|
|
|
|
|
If I were to develop a 3D app that I wanted to port to the 3 major touchscreen mobile operating systems, what language should I choose so that it's easily portable?
I've developed many apps on WinMo, and have just built a hello world app for Android. Is there anything that will work on all 3 platforms with minimal modification?
Thanks!
|
|
|
|
|
Looks like OpenGL ES is an option.
|
|
|
|
|
Sounds like C/C++ will be your best option. Take note that not ever Windows Phone has OpenGL. Android devices have OpenGL but implemented to different levels ( see )[^]
|
|
|
|
|
Dear Experts,
I'm trying to make a VOIP PocketPC app in C# using the waveform Audio Interface (http://msdn.microsoft.com/en-us/library/aa446573.aspx[^]).
I am trying to set the WaveIn to record in GSM format (see [^]), but unfortunately waveInOpen exits with BAD_FORMAT.
Here's the P/Invoke call I am using (taken from MS's P/Invoke Samples)
[DllImport("coredll.dll")]
public static extern Wave.MMSYSERR waveInOpen(ref IntPtr phwi, uint uDeviceID, ref Wave.WAVEFORMATEX pwfx, IntPtr dwCallback, uint dwInstance, uint fdwOpen);
and here's the problematic code:
STRUCTS
[StructLayout(LayoutKind.Sequential)]
public class WAVEFORMATEX
{
public ushort wFormatTag = 0;
public ushort nChannels = 0;
public uint nSamplesPerSec = 0;
public uint nAvgBytesPerSec = 0;
}
[StructLayout(LayoutKind.Sequential)]
public class GSM610WAVEFORMAT
{
public WAVEFORMATEX wfx;
public ushort cbSize;
public ushort wSamplesPerBlock;
}
and code:
Wave.GSM610WAVEFORMAT m_wfmt_gsm;
curDevice = Wave.WAVE_MAPPER;
m_wfmt_gsm = new Wave.GSM610WAVEFORMAT();
m_wfmt_gsm.wfx = new Wave.WAVEFORMATEX();
m_wfmt_gsm.wfx.wFormatTag = (ushort)0x31;
m_wfmt_gsm.wfx.nChannels = 1;
m_wfmt_gsm.wfx.nSamplesPerSec = 8000;
m_wfmt_gsm.wfx.nAvgBytesPerSec = 1625;
m_wfmt_gsm.nBlockAlign = 65;
m_wfmt_gsm.wBitsPerSample = 0;
m_wfmt_gsm.cbSize = 2;
m_wfmt_gsm.wSamplesPerBlock = 320;
result = WaveIn.waveInOpen(ref m_hwi, curDevice, m_wfmt_gsm.wfx, hwnd, 0, Wave.CALLBACK_WINDOW);
Note that is works just fine with regular PCM audio and regular WAVEFORMATEX.
Can anybody give me a clue, please?
Thanks in advance.
Vittorio Sozzi
|
|
|
|
|
I have Several Years of Development Experience in VB.net but i have not work yet on Mobile applications , I want to start Mobile development. Can some one guide me from where i should start , can i do this is vb.net or i have to work in C#.
SOFTDEV
If you have knowledge, let others light their candles at it. [ Let's work to help developers, not make them feel stupid ]
|
|
|
|
|
If you have VS 2005/2008 then you can start wm application development, in this case you have to installed SDK Windows Mobile 6 Standard & Professional and later.
here you can download it Link[^]
here is lots of sample code & video for start development. Link[^]
you can choose any language as per your interest.
Pavan Pareta
|
|
|
|
|
Thank You so Much
SOFTDEV
If you have knowledge, let others light their candles at it. [ Let's work to help developers, not make them feel stupid ]
|
|
|
|
|
Note that if you want to develop for Windows Phone 7 only C# is supported at this time. The Windows Phone 7 developer tools are available as a free download from http://developer.windowsphone.com.
|
|
|
|
|
Hello people.
I've done some small apps (basic operations, without graphics or anything complicated) that I use quite a lot in my job and I'd like to have them in my cell phone. I know C++ (this apps could be done even in C), however I have never used Java. I don't mind to learn new things, but I'd like to do this kind of things as easily as possible.
I have a Nokia 5800 phone, and my question is: would it be easier to port these apps to Symbian or to J2ME? I've heard that Symbian is closer to C++, although maybe J2ME has more documentation. Or maybe it is not worth the trouble to port these kind of programs?
I know there is also Python for cell phones, but I don't have too much free memory in my phone, so I'd consider it as a last resort.
I rely on your experiences to see which one could be better for me. Thanks for your help!
Rad.
|
|
|
|