4

I am trying to use xConnect in a .NET Core application. So i started of by copy pasting the method from the documentation that does this.

https://doc.sitecore.net/developers/xp/xconnect/xconnect-client-api/xconnect-client-api-overview/get-client-outside-sitecore.html

I changed the Thumbprint to the Thumbprint of the certificate First.xconnect_client in the Personal tab in the certificate manager.

 // Valid certificate thumbprints must be passed in
 CertificateWebRequestHandlerModifierOptions options = CertificateWebRequestHandlerModifierOptions.Parse("StoreName=My;StoreLocation=LocalMachine;FindType=FindByThumbprint;FindValue=‎‎‎0b4967ff4e0243c84e6cefafc107058f42bb91d4");

I changed the paths in the 3 client creation lines to my xconnect installation (first.xconnect)

 // This overload takes three client end points - collection, search, and configuration
var collectionClient = new CollectionWebApiClient(new Uri("https://first.xconnect/odata"), clientModifiers, new[] { certificateModifier });
var searchClient = new SearchWebApiClient(new Uri("https://first.xconnect/odata"), clientModifiers, new[] { certificateModifier });
var configurationClient = new ConfigurationWebApiClient(new Uri("https://first.xconnect/configuration"), clientModifiers, new[] { certificateModifier });

I added some code inside the using to check if i could actually write to xConnect.

Sadly on the 3rd non commented line of code i get an exception.

var certificateModifier = new CertificateWebRequestHandlerModifier(options);

System.IO.FileNotFoundException: 'Could not load file or assembly 'Sitecore.Framework.Conditions, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.'

I have however included Sitecore.Framework.Conditions.dll in my references.
I pulled this file from the xConnect installation bin folder.

Does any one know what i am doing wrong?

EDIT:
I have added these references:
- First.Model (this is my custom model)
- Sitecore.Framework.Conditions
- Sitecore.XConnect
- Sitecore.XConnect.Client
- Sitecore.XConnect.Collection.Model
- Sitecore.Xdb.Common.Web
- System.Interactive.Async.Providers

I have added these packages:
- Microsoft.AspNetCore.All
- Microsoft.EntityFrameworkCore
- Newtonsoft.Json
- System.Net.Http.Formatting.Extension

10
  • can you write here what assembly you reference from code? Nov 15, 2017 at 13:25
  • I have added my references and packages Nov 15, 2017 at 13:45
  • Do you have Sitecore.Framework.Conditions in the folder where your app is starting in? Sitecore.Framework.Conditions is a library for code contracts and is extensively used by xDB/xConnect.
    – grg
    Nov 15, 2017 at 13:47
  • I used to have it in the bin folder of my xconnect project, i moved it to the bin folder of my .net Core application, the error still occurs Nov 15, 2017 at 13:52
  • 1
    i can imagine its a reference compatibility issue, check this article for references from .net core to .net framework hanselman.com/blog/…
    – lebeg
    Nov 15, 2017 at 13:52

1 Answer 1

5

Apparently there are some compatibility issues between the .NET Framework and .NET Core. Changing the target framework to .NET Framework 4.6.2. solved this issue for me.
This does however make your .NET Core application bound to windows again because you'll have to use the .NET System libraries.

EDIT:
After changing to .NET Framework 4.6.2 i ran in to a bunch of problems, i'll be describing some down below.

Class library reference broke
I had a reference to a custom model, this reference broke after changing the target framework. To fix this i made my class library in to a nuget package, after adding the nuget package to my project it worked again.

Cannot find library package for [package]
I'm not sure what this error ment but to my understanding there is a bug where razor tries to import libraries that don't exist. Adding the code mentioned in the comment on this github post fixed the problem for me

https://github.com/dotnet/core-setup/issues/2981#issuecomment-322572374

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.