duminică, 29 septembrie 2013

Core C++ Series

I ran into the Stephan T. Lavavej's series on Core C++ on Channel 9 and it brings about many interesting features of C++ that I did not have the opportunity to go through. I plan on following the whole series. Today I watched the first episode and found out a little bit more about C++ name lookup:

Unable to Access the Properties Window in Visual Studio

I had my part of frustration when I fond I could not get hold of the Properties Window in Visual Studio 2005. No matter whether I tried bringing up the window by accessing the menu entry or using the key combination, I could not see the window even though the current view seemed to be switching focus to a new window.
This had to be something about settings, because when I was running a debugging session, the Properties window would be displayed.
I had two hypotheses, with the help of Spy++. I could see the window listed under Visual Studio 2005 in Spy++ so it had to be somewhere.
Inspecting the properties of the Visual Studio 2005 'Properties' window, I got:
So:
1. The window is either off screen and/or
2. The window is of zero width as shown in the rectangle properties.

I tried locating registry settings to specify the location and/ or dimension of the Properties window, but without success.
My solution was to restore Visual Studio's settings for C# development environment (which I spend most of my time in) and this restored the views of all windows to default and now I can access the Properties window as before. ( see this Microsoft How To for details on how to restore your settings)

The new Window Properties in Spy++ now look like this:





After I wrote this post I found this blog entry suggesting a solution for the situation when the 'Properties' window is off screen.

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.