Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何将引用GUID解析为DataContext存储过程_C#_.net - Fatal编程技术网

C# 如何将引用GUID解析为DataContext存储过程

C# 如何将引用GUID解析为DataContext存储过程,c#,.net,C#,.net,我目前有一个使用存储过程的DataContext。问题是最后一个值,当尝试传递GUID值时,它一直给我以下错误消息 参数13必须与'ref'关键字一起传递 使用的代码: Guid g; g = Guid.NewGuid(); testDBAthDataContext dataOut = new testDBAthDataContext(); dataOut.aspnet_Membership_CreateUser("APPNAME", "test@test.com", pass, p

我目前有一个使用存储过程的DataContext。问题是最后一个值,当尝试传递GUID值时,它一直给我以下错误消息

参数13必须与'ref'关键字一起传递

使用的代码:

 Guid g;
 g = Guid.NewGuid();

 testDBAthDataContext dataOut = new testDBAthDataContext();

 dataOut.aspnet_Membership_CreateUser("APPNAME", "test@test.com", pass, passSalt, "test@test.com", "test Quest", "test Awr", true, saveNowDt, createdDt, null, null, g);
testDBAth.designer.cs使用的aspnet_Membership_CreateUser参数的代码布局

IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), applicationName, userName, password, passwordSalt, email, passwordQuestion, passwordAnswer, isApproved, currentTimeUtc, createDate, uniqueEmail, passwordFormat, userId);
            userId = ((System.Nullable<System.Guid>)(result.GetParameterValue(12)));
            return ((int)(result.ReturnValue));

修正了,忘了添加?在Guid变量上

因此,代码现在看起来像:

Guid? g;
g = Guid.NewGuid();
并将ref添加到结束值。按照

代码如下:

dataOut.aspnet_Membership_CreateUser("APPNAME", "test@test.com", pass, passSalt, "test@test.com", "test Quest", "test Awr", true, saveNowDt, createdDt, null, null, ref g);

由于错误,您需要在参数列表的末尾为ref g更改g。如果我更改了end参数,则得到:参数13:无法从“ref System.Guid”转换为“ref System.Guid”。