本文介绍了GUID是全0(零)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我测试了一些发送对象具有的GUID来回WCF服务。在我的web应用程序的测试code,我做了以下内容:
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()
});
由于某些原因,在调用新的GUID()的产生具有全0(零)的GUID是这样的:
For some reason, the call to new Guid() is generating Guids with all 0's (zeros) like this:
00000000-0000-0000-0000-000000000000
什么引起的?
推荐答案
使用静态方法<$c$c>Guid.NewGuid()而不是调用默认的构造函数。
Use the static method Guid.NewGuid()
instead of calling the default constructor.
var responseObject = proxy.CallService(new RequestObject
{
Data = "misc. data",
Guid = Guid.NewGuid()
});
这篇关于GUID是全0(零)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!