У меня есть простой метод WCF службы:сериализация/десериализация параметров - службы WCF вызов не работает
[OperationContract]
public SetupGameResult SetupGame(long player1Id, long player2Id, long myPlayerId)
{
if(player1Id == 0 || player2Id == 0 || myPlayerId == 0)
{
throw new ArgumentException();
}
... // other code
}
Я называю эту службу только в одном месте в моем приложении Silverlight. Здесь:
if(player1Id == 0 || player2Id == 0 || myPlayerId == 0)
{
throw new ArgumentException();
}
// Setup Game
GameServiceClient gameService = new GameServiceClient();
gameService.SetupGameCompleted += new EventHandler<SetupGameCompletedEventArgs>(gameService_SetupGameCompleted);
gameService.SetupGameAsync(player1Id, player2Id, myPlayerId);
Обычно SetupGame является никогда не вызывается с myPlayerId = 0. Но перед тем, как позвонить методу службы, я проверю.
Проблема заключается в том, что метод сервиса вызывается правильно один раз и на втором называют это бросает исключение аргумент, потому что myPlayerId = 0.
Это странно, потому что я проверить перед вызовом, если это 0.
Что проблема не может быть?
EDIT:
Кажется, что там действительно есть проблема с сериализации/десериализации.
Но что такое причинам может иметь?
EDIT 2:
я получаю следующее предупреждение при ПОСТРОЕНИЕ. Это может быть проблема?
Warning 12 Client proxy generation for service 'Car_Motion.Web.Services.GameService' failed: Generating metadata files...
Warning: Unable to load a service with configName 'Car_Motion.Web.Services.GameService'. To export a service provide both the assembly containing the service type and an executable with configuration for this service.
Details:Either none of the assemblies passed were executables with configuration files or none of the configuration files contained services with the config name 'Car_Motion.Web.Services.GameService'.
Warning: No metadata files were generated. No service contracts were exported.
To export a service, use the /serviceName option. To export data contracts, specify the /dataContractOnly option. This can sometimes occur in certain security contexts, such as when the assembly is loaded over a UNC network file share. If this is the case, try copying the assembly into a trusted environment and running it.
Заранее спасибо
Неправильная сериализация/десериализация, которая дает значение по умолчанию. –
Похоже. Все параметры равны 0. Это действительно странно. – Ben
Где устанавливается mPlayerId? Может ли оно быть установлено на ноль между вашим чеком и вашим служебным звонком? – Paddy