Pergunta

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?

Foi útil?

Solução 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.

Outras dicas

Is the code contract supported on actual device?

Yes.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top