locked
Conditional code with URT_MINCLR and CF services does not work RRS feed

  • Question

  • I have a baffling problem that I can repro very easily. It appears that the main service of the desktop version of a solution that has both desktop and CF projects gets the compiled CF version of the code.

     

    1. Create a new service:

    dssnewservice /s:TestCF

     

    2. Edit the service and insert the following into Start()

     

    Code Snippet

    base.Start();

    // Add service specific initialization here.

    #if URT_MINCLR

    LogInfo(LogGroups.Console, "Starting CF version");

    #else

    LogInfo(LogGroups.Console, "Starting Desktop version");

    #endif

     

     

    Notice the color-coding which shows that for the desktop version the correct line of code will be executed.

     

    3. Create a CF service.

    dssnewservice /generatecfproject:TestCF.csproj

     

    4. Start Visual Studio and add this as an Existing project.

     

    5. Recompile everything, i.e. both projects, using Rebuild Solution. (The desktop version is built first.) Then run the desktop version.

     

    The output will show CF version! Furthermore, you cannot set a breakpoint on the line of code for the desktop version because it does not exist in the executable.

     

    In Visual Studio, depending which project you open TestCF.cs from you will see the correct line greyed out.

     

    It appears to me that after the desktop version has compiled, the CF one is compiled and the desktop version is relinked with the wrong object file.

     

    Am I doing something wrong? Any suggestions?

     

    Thanks,

    Trevor

    Friday, February 15, 2008 2:02 PM

Answers

  • I also had the same problem!

    I use NET_CF20 instead of URT_MINCLR, and it's ok for me.

    It seems that you can also delete the symbol URT_MINCLR in the cf.project.csproj file, in the <DefineConstants> section when defining the full framework project file as a <DependProjects> item, but I'm not sure there's no side effect.
    Monday, February 18, 2008 4:25 PM

All replies

  • actually, thi sis possible since w ehave to compile the full Desktop version of your service, with UTR_MINCLR enabled, as a middle step in the CF compilation process. But that should go just to the bin\folder under the project. VS might get the symbols confused which you can manually correct by pointing VS to the right symbol location.

     

    Solution: Dont build CF last. When working with full desktop, just compile your full service last.

     

    Sunday, February 17, 2008 4:13 AM
  • I still think there is a problem. I tried the following:

     

    1. Set up a dependency so that the CF version builds first.

    2. Clean the solution

    3. Rebuild all

     

    Looking at the output, there is no compilation of the desktop version without URT_MINCLR. As you say, the desktop version is compiled during the building of the CF version in order to create the proxy. This is copied to the bin folder.

     

    When it gets to the step for building the desktop version, it simply copies across the DLL without rebuilding it with the correct preprocessor definitions. I assume that VS thinks there have been no changes so it does not recompile.

     

    Here is an extract from the build log. Notice that the second "Build started" does not run the compiler, but launches straight into DssProxy.

     

    Code Snippet

    ------ Build started: Project: cf.TestCF, Configuration: Debug Any CPU ------
    c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig /unsafe- /checked- /nowarn:3003,1701,1702 /nostdlib+ /errorreport:prompt /warn:1 /baseaddress:285212672 /define:DEBUG;TRACE;NET_CF20;URT_MINCLR;WindowsCE /reference:"C:\Microsoft Robotics Studio (1.5)\bin\CF\cf.Ccr.Core.dll"

    ...

    Compile complete -- 0 errors, 0 warnings
    cf.TestCF -> C:\Microsoft Robotics Studio (1.5)\bin\CF\cf.TestCF.Y2008.M02.dll
    c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig /unsafe- /checked- /nowarn:3003,1701,1702 /nostdlib- /warn:1 /baseaddress:285212672 /define:TRACE;URT_MINCLR /reference:"c:\microsoft robotics studio (1.5)\bin\Ccr.Core.dll" /reference:"c:\microsoft robotics studio (1.5)\bin\DssBase.dll"

    ...

    ------ Build started: Project: TestCF, Configuration: Debug Any CPU ------
    TestCF -> C:\Microsoft Robotics Studio (1.5)\bin\TestCF.Y2008.M02.dll
    "C:\Microsoft Robotics Studio (1.5)\bin\dssproxy.exe" /dll:"C:\Microsoft Robotics Studio (1.5)\bin\TestCF.Y2008.M02.dll" /proxyprojectpath:"C:\Microsoft

     

     

     

     

    How can I force the desktop version to be rebuilt with the correct definitions?

     

    Trevor

     

    Sunday, February 17, 2008 6:36 AM
  • I also had the same problem!

    I use NET_CF20 instead of URT_MINCLR, and it's ok for me.

    It seems that you can also delete the symbol URT_MINCLR in the cf.project.csproj file, in the <DefineConstants> section when defining the full framework project file as a <DependProjects> item, but I'm not sure there's no side effect.
    Monday, February 18, 2008 4:25 PM
  • Thanks Marc, that's a good suggestion. I don't know why I did not think of it - too focused on URT_MINCLR I suppose.

     

    However, it is even more subtle than that. I defined a preprocessor constant USE_GAME_CONTROLLER for the desktop version, which is NOT defined when the code for the CF proxy is built. Therefore the desktop version does not include any game controller code, but it should.

     

    Anyway, I am now using NET_CF20 as you suggest. I have added the Game controller as a reference in the CF project and I just ignore the warning when I rebuild which says that cf.GameController.Y2006.M09.Proxy could not be found, and the error from DssProxy which exits with code 20. All the DLLs get built. I've tested the desktop version and it seems to be OK, so I am hoping that the CF version works as well.

     

    Thanks,

    Trevor

     

     

    Tuesday, February 19, 2008 2:39 AM