As discussed in the previous article, 17.12, there is an issue with Compact 2013 C# apps that are a client of a web service in that the VS2012 Visual Designer does not support adding a web reference for .NET CF 3.9 apps. The workaround is to build a similar app as SmartDevice project in VS2008 and to manually copy the required the required bits into the Compact 2013 project. Whilst overview of how to do this is contained in that previous article, it is lacking in detail. This article provides that detail.
NOTE: On this page, a space has been added in front of the / character in closing XML tags. This is because of HTML escape character sequences.
The .csproj files are essentially XML and therefore viewable in a text editor or XML editor. To do so it is simplest to copy the files and give them a .txt or .xml extension depending upon which editor is to be used. To compare the two files copy them to a temporary folder and give them a .txt or .xml extension. Open them both side-by-side in the same editor and visually inspect both to make a comparison. Focus upon the XML structure of the files and so an XML editor may be more conducive to determining the differences.
The structure of the project file from an XML perspective is:
<Project DefaultTargets="Build" xmlns=http://…/developer/msbuild/2003 ToolsVersion="3.5">
· PropertyGroups
· ItemGroups
· Imports
< /Project>
Its interesting that the Compact 2013 ToolsVersion is 4.0, not 3.9. The TargetFrameworkVersion is 3.9 though.
The differences center upon the ItemGroups. The second ItemGroup requires the insertion of an item at its end. Also a number of ItemGroups need to be inserted after that second ItemGroup..
A text comparator such as BeyondCompare. An XML comparator will give more structure to the comparison. In this example, the XML comparator, DiffDog , was used:
1. Make sure you have backed up the project file.
2. Open the Managed Code project file ( .csproj ) in Notepad or another text editor.
3. Locate the second ItemGroup, It starts with:
xml version="1.0" encoding="utf-8" ?>
<ItemGroup>
<Compile Include="Form1.cs">
<SubType>Form< /SubType>
Compile>
....
< /ItemGroup>
4. At the bottom of that ItemGroup insert the following:
<Compile Include="Web References\WebReference\Reference.cs">
<AutoGen>True< /AutoGen>
<DesignTime>True< /DesignTime>
<DependentUpon>Reference.map< /DependentUpon>
< /Compile>
5. Then just below that ItemGroup insert the follow ItemGroups:
<WebReferences Include="Web References\" />
<WebReferenceUrl Include="http://192.168.2.109/WebSite/Service.asmx">
<UrlBehavior>Static< /UrlBehavior>
<RelPath>Web References\WebReference\< /RelPath>
<UpdateFromURL>http://192.168.2.109/WebSite/Service.asmx< /UpdateFromURL>
<ServiceLocationURL>
< /ServiceLocationURL>
<CachedDynamicPropName>
< /CachedDynamicPropName>
<CachedAppSettingsObjectName>
< /CachedAppSettingsObjectName>
<CachedSettingsPropName>
< /CachedSettingsPropName>
< /WebReferenceUrl>
<None Include="Web References\WebReference\Service.wsdl" />
<None Include="Web References\WebReference\Reference.map">
<Generator>MSDiscoCodeGeneratorGenerator>
<LastGenOutput>Reference.cs< /LastGenOutput>
< /None>
<None Include="Web References\WebReference\Service.disco" />
.. where the URL (in two places) is the web service URL.
7. Save and close the file
8. Reopen the project in VS2012 and check that the web reference is present and usable.
Click here to provide feedback and input