C# – Guid is all 0’s (zeros)

cguidnetwcfweb services

I'm testing out some WCF services that send objects with Guids back and forth. In my web app test code, I'm doing the following:

var responseObject = proxy.CallService(new RequestObject
{
    Data = "misc. data",
    Guid = new Guid()
});

For some reason, the call to new Guid() is generating Guids with all 0's (zeros) like this:

00000000-0000-0000-0000-000000000000

What could be causing this?

Best Answer

Use the static method Guid.NewGuid() instead of calling the default constructor.

var responseObject = proxy.CallService(new RequestObject
{
    Data = "misc. data",
    Guid = Guid.NewGuid()
});