posts - 20 , comments - 57 , trackbacks - 0

My Links

News

Archives

Post Categories

Image Galleries

Other Windows CE links

Windows Embedded Compact 2013 Smart Device application projects in Visual Studio 2012 (and their bugs)

After I built my first new Windows Embedded Compact 2013 image (named “MyDevice8”) and corresponding SDK, I was eager to test how you can build Smart Device applications with VS2012. I mean with that: without the need to install Platform Builder, but only the SDK and create a VS2012 Smart Device application project (as you would do for a desktop WIN32 project).

Before you can start however creating a new “MyDevice8” based project, these are the installation steps to follow:

  • Install Visual Studio 2012 Professional (or higher)
  • Install Visual Studio Update 2 (or higher)
  • Install Application Builder for Visual Studio 2012. Download it from the web or you can find the standalone installer on the Windows Embedded Compact 2013 DVD.
  • Install Xaml tools for Windows Compact Edition 2013. I had to, else my “MyDevice8” SDK failed to install. You can find the standalone installer on the Windows Embedded Compact 2013 DVD.
  • Install your Windows CE 8 “MyDevice8” SDK.

Note: I didn’t install Platform Builder for Windows Compact Edition 2013.

Ok. The next step I wanted to do is to convert an existing Smart Device application project - built for Windows CE 6/7 with VS2008 – to a VS2012 project. So I launched the New Project Wizard to create a new C++ ATL COM DLL project, followed by a C++ library and a C++ Console application. Finally I created a .NETCF C# Device Application that uses the ATL COM DLL via COM interop.

With all of them I had troubles! Bummer. To be honest, Microsoft did not do its homework (test work) properly. By far NOT!

What follows is a description of the problems I encountered and their workarounds. I ran the same wizards for desktop “WIN32” projects to show the differences (and to find out what I needed to change myself in the “MyDevice8” targeted project files)

C++ ATL COM DLL

The following screenshot shows that - after you created the ATL COM DLL project - the “deployment” and “debugging” sections are missing.

  • The “deployment” section is required to specify where the DLL should be deployed for debugging
  • The “debugging” section is required to specify the “Remote Executable” and “CommandLine Arguments” in case you wish to debug the DLL from this executable.

 

WorkAround:

To deploy the ATLDll.dll to your device, you have to manually copy the DLL to the right place. You can automate that by making a small “WIN32” deploy.exe program that uses FtpWebRequest to copy the file to the Ftp server in Windows CE 8 (you have to include it into your image). Run this deploy.exe as post-build step of your ATL DLL COM project. Check also my posts on Ftp File Server and FtpWebRequest.

In folder C:\WINCE800\public\dcom\sdk\samples\regsvr you find the sources for building your own version of regsvr32.exe for Windows CE. Create a new Smart Device Console Application, and compile the regsvr.cpp file in the project.

With this regsvrce.exe, you can register the COM DLL yourself as follows “regsvrce.exe <path>AtlDll.dll”, to unregister use “regsvrce.exe /u <path>AtlDll.dll”. In previous versions of Windows CE, <path> may not embed spaces. This problem seems to be fixed in Windows CE 8. You only have to repeat this register step if you change the IDL COM interface.

C++ Librarian

The Librarian section (Linker) does not show up in the project settings

Workaround:

You can access the linker options by editing the corresponding vcxproj file. Have a look in the “WIN32” configuration for the syntax. E.g.

<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|MyDevice8'">

   <ClCompile>

      <WarningLevel>Level3</WarningLevel>

      <Optimization>MaxSpeed</Optimization>

      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>

   </ClCompile>

   <Link>

      <GenerateDebugInformation>true</GenerateDebugInformation>

   </Link>

</ItemDefinitionGroup>

.NETCF C# referencing a ATL COM DLL

Consider the C++ATL DLL we built in the first step. I added a ‘Simple ATL object’ SampleClass to it and implemented a method “DoSomething()”. If you wish to add a COM reference to this ATLDll.dll from our C# Device Application, there are 3 ways to do that in Visual Studio 2008:

  1. Browse to the COM ATLDll.dll. If the TLB information is added in (normally it is so in the resource), the .NETCF IDE can found what is needed [*]
  2. Browse to the COM ATLDll.tlb. The .NETCF IDE can found immediately what is needed [*]
  3. Generate a COM interop C# DLL with TlbImp.exe tool based on the ATLDll.tlb info.

Note [*] On desktop Windows “WIN32” configuration the ATL COM DLL needs to be registered too, not so for a Smart Device ATL COM DLL (how could it be?)

In Visual Studio 2012 none of the 3 methods work.

Workaround:

If we return to the csproj file and steal the syntax from a desktop “WIN32” Configuration equivalent, we can make it work again!

Copy the “Win32” version from WindowsFormsApplication.csproj

<ItemGroup>

    <Reference Include="ATLProject_Idl">

        <HintPath>..\..\ATLProject\ATLProject\Debug\ATLProject_Idl.dll</HintPath>

        <EmbedInteropTypes>True</EmbedInteropTypes>

    </Reference>

    <Reference Include="System" />

    …

</ItemGroup>

And paste (and edit) to the “MyDevice8” DeviceApplication.csproj file (in the right place, else you screw up!)

<ItemGroup>

    <Reference Include="ATLDll_Idl">

        <HintPath>..\..\ATLDll\ATLDll\Debug\ATLDll_Idl.dll</HintPath>

        <EmbedInteropTypes>True</EmbedInteropTypes>

    </Reference>

    <Reference Include="System" />

    …

</ItemGroup>

Et voila, the AtlDll_Idl COM interop appears in your C# .NETCF project, ready to be used.

I also tried to play with the files in the C:\Program Files\MSBuild\Microsoft\WindowsEmbeddedCompact\v8.0 folder, but had no luck. I only caused damageL

Although I describe some workarounds, they are not convenient, error prone and cumbersome. I reported these problems to Microsoft, and I am currently waiting for feedback. Stay tuned!

UPDATE: Microsoft confirmed these bugs and they will be fixed in Windows Embedded Compact 2013 Update 1 and the next release of Application Builder (Visual Studio 2013)

 

Print | posted on Friday, September 6, 2013 10:54 PM | Filed Under [ Windows CE Windows Embedded Compact Microsoft Visual Studio 2012 Smart Device application ]

Feedback

Gravatar

# re: Windows Embedded Compact 2013 Smart Device application projects in Visual Studio 2012 (and their bugs)

The manual editing of the project file may fix the compile time, but you will die at runtime trying to call the interface. There are numerous problems with VS2012/WEC2013 and I have 6 open MSDN service requests. There is some overlap from above, but MS acknowleges them as all NEW:
- Can't redeploy project. Problem is some reference dlls were read-only. Remove read-only from ALL deployed files
- VS2012 doesn't deploy subfolders defined in project. I have a beta fix for this
- can't deploy anywhere but \temp\projname
- can't debug or deploy dll projects
- ATL wizard doesn't give the "include MFC support" option like VS2008/WEC7
- the tlbimp problem described in this blog
- VS2012 deletes all files in the deployment folder that don't belong to the project.
12/17/2013 10:06 PM | david schneider
Gravatar

# re: Windows Embedded Compact 2013 Smart Device application projects in Visual Studio 2012 (and their bugs)

Note you must mark the ATL COM object as ThreadingModel Free or the calls from .Net CF to the COM object will fail because it will look for a proxy to use to marshal the data.
12/27/2013 10:02 PM | Mark
Gravatar

# re: Windows Embedded Compact 2013 Smart Device application projects in Visual Studio 2012 (and their bugs)

I am not able to register the ATL dll created. I get "User stack overflow exception". can anyone help me?
1/16/2014 11:16 AM | Venkatesh
Gravatar

# re: Windows Embedded Compact 2013 Smart Device application projects in Visual Studio 2012 (and their bugs)

I am not able to register the ATL dll created. I get "User stack overflow exception". can anyone help me?
1/16/2014 11:16 AM | Venkatesh
Gravatar

# re: Windows Embedded Compact 2013 Smart Device application projects in Visual Studio 2012 (and their bugs)

Make sure you have COM (DCOM) enabled in your CE image.
Debug your COM DLL by running it together with C:\WINCE800\public\dcom\sdk\samples\regsvr. Build this as a separate executable project. With both projects (COM DLL + regsvr,exe), you can debug what is going wrong. If it is a real stack overflow, specify stack size in your COM DLL and regsvr.exe project.
1/16/2014 9:11 PM | Werner
Gravatar

# re: Windows Embedded Compact 2013 Smart Device application projects in Visual Studio 2012 (and their bugs)

Exception occurs inside _AtlModule.DllRegisterServer(). I tried increasing the stack reserve size (under proj\linker\system). Still I receive the same problem.
I have selected threading model as free. If anybody having simple ATL project (like simple calc) for WEC2013 can you please share it?
1/17/2014 3:38 PM | Venkatesh
Gravatar

# re: Windows Embedded Compact 2013 Smart Device application projects in Visual Studio 2012 (and their bugs)

I am receiving the same "User stack overflow exception". Can anyone help?
1/20/2014 11:42 AM | Zahir Hussain
Gravatar

# re: Windows Embedded Compact 2013 Smart Device application projects in Visual Studio 2012 (and their bugs)

Does anyone know when can we expect Windows Embedded Compact 2013 Update 1?
2/5/2014 1:08 PM | Gregor Krebs
Gravatar

# re: Windows Embedded Compact 2013 Smart Device application projects in Visual Studio 2012 (and their bugs)

Just found that WEC Update 1 comes somewhen "in spring" according to this:
http://blogs.msdn.com/b/windows-embedded/archive/2014/02/05/coming-soon-visual-studio-2013-and-other-updates-to-compact-2013.aspx
Do you think this will include fixes to these issues? Do we have to upgrade to VS 2013 then?
2/24/2014 12:28 PM | Diddy
Post A Comment
Title:
Name:
Email:
Comment:
Verification:
 

Powered by: