Question

I use Code Contracts in my code, my app runs fine on the emulator. When I deploy it on a device, it fails/crashes whenever Contract statement is executed.

 public static HTTPRequest CreateGetRequest(string url,
                                        bool shouldUseCustomTimeout)
        {
            // preconditions
            Contract.Requires<ArgumentException>(!string.IsNullOrWhiteSpace(url));

            return new HTTPRequest(url,
                                    System.Net.Http.HttpMethod.Get,
                                    shouldUseCustomTimeout);
        }

Is the code contract supported on actual device? Should I install a separate extension?

Was it helpful?

Solution 2

I got it working by following the steps on this blog: http://blog.stephencleary.com/2011/01/simple-and-easy-code-contracts.html

It turns out that I had to enable for the library projects too. I was setting code contracts only for the test app.

OTHER TIPS

Is the code contract supported on actual device?

Yes.

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