C# client sample fails with "Expected Version" exception

Hi,

When trying the newest (master) C# client samples, all the test that do “GetById” fails because the expected version is incorrect.

Is that a known issue with the current code or?

Thanks.

Can you be a bit more specific?

Specifically where the code is from?

Could be when es took out the $streamcreated events for version 2. Change your math or write a empty/fake event when creating the stream.

Thanks all,

This is what I did:

  1. D/L ES from http://download.geteventstore.com/ and run the server.

  2. Tested with curl that it works.

  3. D/L samples from https://github.com/EventStore/getting-started-with-event-store.

  4. Rebuild samples and run “GetEventStoreRepository.Tests.dll” from NUnit.

Of the tests in that assembly, 8 runs with success and 4 fails with this exception:

GetEventStoreRepository.Tests.GetEventStoreRepositoryIntegrationTests.CanGetSpecificVersionFromFirstPageById:

GetEventStoreRepository.AggregateVersionException : Requested version 65 of aggregate ‘c416df19-aa37-41fd-8909-850d6d3339ec’ (type TestAggregate) - aggregate version is 66

Well I tried the branch called “WithoutStreamCreated” (https://github.com/EventStore/getting-started-with-event-store/tree/WithoutStreamCreated) but that seems to make things worse :slight_smile: - didn’t try it on a new database though…

In any case, with the previous sample I am able to store the aggregate in the ES - I just can’t update it.

I forgot to mention:

I’m using version 2.0.1.

From looking in the test samples, I can see, that I am able to create and get an aggregate in the ES, but I am not able to update it.

I probably need to look over that source code for the samples and update it - I’ll try to do that shortly.

My guess is the expected version is off by one (without looking at the code again!)

I am looking to use binaries 2.0.1, for repository code would I look at:

https://github.com/EventStore/getting-started-with-event-store/tree/WithoutStreamCreated

or

https://github.com/EventStore/getting-started-with-event-store

Also, would there be any major changes for repository code for v3 which I believe is due to be released soon?

Hi,

The removal of the $StreamCreated events happened between versions 1 and 2, so you don’t need to account for them in new systems which haven’t been upgraded between versions.

There are some major changes between v2 and v3 related to the client API’s synchronous overloads of naturally async methods - consequently you’ll either need to make your code async or put in .Wait() and .Result’s on your calls to replicate what was happening
before.

I’d strongly recommend starting with v3 at this point, it will be released out of RC on the 17th September.

James

Thanks James, will work with v3 - can we use the EventStore.ClientAPI 2.0.2 with v3 (i havent been able to find ClientAPI v3 C# libs)?

Chris,

Do -Pre on NuGet - 3.0.0-rc9 is up on NuGet. The wire protocol is basically the same (some minor operations differ) but it’s better to use v3 as that’s what it will look like in the future.

Cheers,

James