Question

In my new CF winform I suddenly cannot code int.TryParse(), with VS showing the message 'int' does not contain a definition for 'TryParse', but in another form this is no problem. So strange!

I tracked this down, with Go To Definition, that the old form uses int from C:\DOCUME~1\XPMUser\LOCALS~1\Temp\3464$CommonLanguageRuntimeLibrary$v2.0.50727\System.Int32.cs which of course has TryParse(), while my new code uses int from C:\DOCUME~1\XPMUser\LOCALS~1\Temp\3464$mscorlib.dll$v2.0.50727\System.Int32.cs, which has no TryParse().

In the list of references of the project, there is a mscorlib, and by double-clicking I arrive in the Object Browser at mscorlib [Compact Framework], while the object browser also shows an entry mscorlib, i.e. without the CF remark.

This did not help me much, hopefully someone can help me get TryParse() back.

Here is sample code with the error:

using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace SIClient2.WebServices
{
    class Test
    {
        public Test()
        {
            int i;
            int.TryParse("123", out i); // <== 'int' does not contain a definition for 'TryParse'
        }
    }
}

The code without the error is part of a winform. Does that make a diff?

Was it helpful?

Solution

This turned out to be one of the things you should not do on a Friday afternoon. The solution has several projects: a client on a mobile device, hence CF. A server for web services. And a test project that calls the web services directly for easier debugging, with desktop winforms, i.e., without CF, and with int.TryParse() ... :-) We are also working on upgrading to more modern mobile devices which will hopefully avoid CF.

The bottom line is that VS is not that bad, but not very easy either. Most errors are valid pointers to real problems. On the other hand regrettable that CF is so limited, while today's mobile devices are not that petite anymore.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top