sâmbătă, 31 august 2013

How to Check for Windows CE Platform Builder Updates

In order to verify whether you have the latest version of Windows CE Platform Builder installed you can use the CEUpdateCheck.exe tool which is typically found in:
C:\Program Files\Microsoft Platform Builder\6.00\cepb\SustainedEngineering
Running this tool and selecting the "Verify Updates" button will list the updates that you have installed and the ones that you have not yet installed, categorized by year. This will allow you to locate and install the latest update pack much easier on the Microsoft website.
The latest release is R3, and after that there is a cumulative update and for 2013 there are monthly updates that need to be installed one at a time.

miercuri, 14 august 2013

Passing structures to C++ using C#

An ever reoccurring problem for developers having to integrate legacy C++ libraries with .NET Framework projects is passing structures to the C++ layer and getting back the results.
I have searched the web and I have found a few threads looking into this problem as well as the official MSDN documentation.

http://stackoverflow.com/questions/3939867/passing-a-structure-to-c-api-using-marshal-structuretoptr-in-c-sharp
http://objectmix.com/dotnet/796796-ptrtostructure-failing-structure-must-not-value-class.html
http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.structuretoptr.aspx

For my own needs, I am using the following code snippet, that is used to pass a structure by reference to a C++ function and get back the structure filled with the data.

In the code below, the StructureToPass structure must match the definition of the equivalent C++ structure and must be decorated with the StructLayout(LayoutKind.Sequential) attribute.

[StructLayout(LayoutKind.Sequential)]
public struct StructureToPass  
{
        public uint x;       
        public float y;
        public float z;
}

StructureToPass tsData = new StructureToPass();
IntPtr strPtr = Marshal.AllocHGlobal(Marshal.SizeOf(tsData));

try
{ 

    Marshal.StructureToPtr(tsData, strPtr, false);

    if ( 0 == GetStructureFromCPP(strPtr))
    {
       
tsData = (StructureToPass)Marshal.PtrToStructure(strPtr, typeof(StructureToPass));

    }
}
}
catch (Exception ex)
{
}
finally
{
   
Marshal.FreeHGlobal(strPtr);
}
 

Visual Studio 2005 C1001 compiler error

While compiling a C++/CLI project from within Visual Studio 2005 I received error C1001 - internal compiler error, file msc1.cpp line 1393. The reported error seemed to originate in a header file containing the class definition.
Cleaning and rebuilding the project helped me solve the issue.

More on internal compiler errors can be found here:
http://support.microsoft.com/kb/305980
though it was not the case for my particular situation.