How to get package Microsoft.CrmSdk.XrmTooling.CoreAssembly working with other dependencies - dynamics-365

I've added Microsoft.CrmSdk.XrmTooling.CoreAssembly so that I can connect using new CrmServiceClient(connectionString) rather than using OranisationServiceProxy as CrmServiceClient is meant to work better for long running data replication jobs.
However, I now get this exception
System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Rest.ClientRuntime,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
when I try to access the key vault
AzureServiceTokenProvider azureServiceTokenProvider = new AzureServiceTokenProvider();
var keyVaultClient = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(azureServiceTokenProvider.KeyVaultTokenCallback));
This is my current list of dependencies:
<PackageReference Include="AdaptiveCards" Version="1.2.2" />
<PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.4" />
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.3.1" />
<PackageReference Include="Microsoft.CrmSdk.XrmTooling.CoreAssembly" Version="9.1.0.13" />
<PackageReference Include="Microsoft.Graph" Version="1.17.0" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.4.0" />
Any suggestions?

Related

Error processing method: 'Android.Gms.Tasks.CancellationToken Google.Places.FetchPhotoRequest::get_CancellationToken()'

I updated my project to use the Xamarin.Google.Android.Places v1.1.0.1 package from the NuGet package Manager.
But the project build fails after upgrading to the new Places package.
I have tried uninstalling and reinstalling the Places package and it's dependencies, deleting the bin and obj folders, but none of it really helped.
This is the following error that I amgetting while building the solution:
The "LinkAssemblies" task failed unexpectedly.
Mono.Linker.MarkException: Error processing method: 'Android.Gms.Tasks.CancellationToken Google.Places.FetchPhotoRequest::get_CancellationToken()' in assembly: 'Xamarin.Google.Places.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve Android.Gms.Tasks.CancellationToken
The issue was that the latest stable GooglePlayServices APIs were not supported by the Xamarin.Google.Android.Places API. I added the following package versions of the required dependencies and the error was gone.
<PackageReference Include="Xamarin.Android.Volley" Version="1.1.1.1" PrivateAssets="all" />
<PackageReference Include="Xamarin.Google.Android.Places">
<Version>1.1.0.1</Version>
</PackageReference>
<PackageReference Include="Xamarin.Android.Glide" Version="4.9.0" PrivateAssets="all" />
<PackageReference Include="Xamarin.Android.Glide.DiskLruCache" Version="4.9.0" PrivateAssets="all" />
<PackageReference Include="Xamarin.Android.Glide.GifDecoder" Version="4.9.0" PrivateAssets="all" />
<PackageReference Include="Xamarin.GooglePlayServices.Base" Version="71.1601.0-preview3" PrivateAssets="all" />
<PackageReference Include="Xamarin.GooglePlayServices.Basement" Version="71.1610.0-preview3" PrivateAssets="all" />
<PackageReference Include="Xamarin.GooglePlayServices.Clearcut" Version="71.1600.0-preview3" PrivateAssets="all" />
<PackageReference Include="Xamarin.GooglePlayServices.Location" Version="71.1600.0-preview3" PrivateAssets="all" />
<PackageReference Include="Xamarin.GooglePlayServices.Maps" Version="71.1600.0-preview3" PrivateAssets="all" />
<PackageReference Include="Xamarin.GooglePlayServices.Phenotype" Version="71.1600.0-preview3" PrivateAssets="all" />
<PackageReference Include="Xamarin.GooglePlayServices.Places.PlaceReport" Version="71.1600.0-preview3" PrivateAssets="all" />
<PackageReference Include="Xamarin.GooglePlayServices.Tasks" Version="71.1601.0-preview3" PrivateAssets="all" />
<PackageReference Include="Xamarin.Google.AutoValue.Annotations" Version="1.6.5" PrivateAssets="All" />
<PackageReference Include="GoogleGson" Version="2.8.5" PrivateAssets="All" />
<PackageReference Include="Xamarin.Build.Download">
<Version>0.4.11</Version>
</PackageReference>

How to consume a .net4.7 app from .net core 2.0

I have a .net core test app that's referencing a .net framework 4.7.1 project. I've updated the project file of the .net core project so that it looks like this...
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net471</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0-preview-20170628-02" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PushNotifications\PushNotifications.csproj" />
</ItemGroup>
</Project>
When I debug a test, I get..
Catastrophic failure: System.TypeInitializationException: The type
initializer for 'Xunit.DiaSession' threw an exception. --->
System.IO.FileNotFoundException: Could not load file or assembly
'System.Reflection.TypeExtensions, Version=4.1.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The
system cannot find the file specified.
Adding System.Reflection.TypeExtensions to either project has no effect.
What else do I need to do?

No executable found matching command "dotnet-ef" (Csproj)

I started a project on a Mac using VS Code and ASP.NET Core MVC, here is my csproj:
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.3.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
</ItemGroup>
I always get "No executable found matching command "dotnet-ef""
I tried it on Windows 10 and I get the same result.
What am I missing?
Added this to make it work:
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version = "1.0.0"/>
</ItemGroup>
From inside the folder containing the csproj file, Add the following to the csproj file:
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeFrameworkVersion>2.0.5</RuntimeFrameworkVersion>
</PropertyGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
</ItemGroup>
Now include the needed dependencies by executing the following commands:
dotnet add package Microsoft.EntityFrameworkCore
dotnet add package Microsoft.EntityFrameworkCore.Design
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
dotnet add package Microsoft.EntityFrameworkCore.Tools.DotNet
Restore the project so that all dependencies are checked upon
dotnet restore
In order to make sure it all went ok, run the following command
dotnet ef
A screen with the basic dotnet ef command usage should appear
Check if the project is still building:
dotnet build
Generate the scaffold from your database with the following command:
dotnet ef dbcontext scaffold "Server=<your_server_address[,port_number]>;Initial Catalog=<your_db>;User Id=<your_user>;Password=<your_password>" Microsoft.EntityFrameworkCore.SqlServer -f -c YourDbContext -o Db --json
The command above can be described as the one responsible for reading out your database and generating your scaffold poco entity classes and the dbcontext file. It requires a basic working connection string, the parameter f forces the overwrite, the c gives the context a name, the o determines the output folder and the namespace for the created classes and the json parameter outputs the command result in json instead of a zero stout.
it is nice to keep this command at hand, it will be used anytime changes from the database must be reflected upon the ORM

Use Application Insight with ASP API Core

Community
I'm having troubles connecting Application Insights to my ASP WEB API Core.
Following standard manuals I still cannot find any record in my AppInsights account.
I used a lot of manuals, but the are pretty identical and describe how to configure App Insights for ASP Core (not API Core).
So I'm wondering is some special configuration (or nuget package or whatever) is required to make AppInsights track requests to my API service?
Once I cannot make AppInsights work out of box, I still can create instance of TelemetryClient and publish data manually, but this is not desirable in my case.
Important note: I'm using VS 2017 RC, Web APi Core project (csproj)
UPD
csproj file content:
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.0</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0-msbuild1-update1" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0-msbuild1-final" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0-msbuild2-update1" />
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0-msbuild1-update1" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0-msbuild1-final" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0-msbuild2-update1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="1.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.0.1" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.2.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.ResponseCompression" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0-msbuild1-final" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="1.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.0.0-msbuild2-final" />
<PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Https" Version="1.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="1.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="Swashbuckle.SwaggerGen" Version="6.0.0-beta901" />
<PackageReference Include="Swashbuckle.SwaggerUi" Version="6.0.0-beta901" />
</ItemGroup>
</Project>
Configuration in Startup.cs:
public class Startup
{
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
if (env.IsDevelopment())
{
// This will push telemetry data through Application Insights pipeline faster, allowing you to view results immediately.
builder.AddApplicationInsightsSettings(true);
}
builder.AddEnvironmentVariables();
Configuration = builder.Build();
}
public IConfigurationRoot Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddApplicationInsightsTelemetry(Configuration);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug(LogLevel.Trace);
loggerFactory.AddConsole(LogLevel.Error);
app.UseApplicationInsightsExceptionTelemetry();
app.UseMvc();
}
If you're using the "new" asp.net core in VS2017, then the old instructions are wrong, as they are for the previous xproj based asp.net core implementations.
If you create a new asp.net core web project in VS2017, ApplicationInsights will be already installed from the start, and should be versions:
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.2.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
(or newer, if the asp.net core team has updated them at all)
Those projects will already have Application Insights wired up as well, not in Startup.cs (that's the old way), but in Program.cs:
new WebHostBuilder()
...
.UseApplicationInsights() // this starts up appinsights in asp.net core now
...
.UseOtherThings();
and possibly in web templates, like:
#inject Microsoft.ApplicationInsights.AspNetCore.JavaScriptSnippet JavaScriptSnippet
at the top, and
#Html.Raw(JavaScriptSnippet.FullScript)
inside the bottom of the <head> tag.
if you're migrating from a previous version of asp.net core and app insights, you'll also have to remove things like:
#Html.ApplicationInsightsJavaScript(TelemetryConfiguration)
from _Layout.cshtml and replace them with the lines above, and you can remove all of the lines like:
app.UseApplicationInsightsExceptionTelemetry();
in Startup.cs (if you're using 2.x versions of the packages, i believe those items will all show deprecation warnings as well, as they're no longer needed)
VS2017's official release notes include this information as a section in the "known issues" for application insights
The issue is solved thanks to this article
There are 2 points I missed in my configuration:
1. In csproj should be referenced package "Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0-beta1"
2. In class Startup, method Configure I missed to add app.UseApplicationInsightsRequestTelemetry();
When I changed what described above AppInsights has started to track all requests

Error when starting ASP.NET Core web app: "Unable to start dotnet.exe. The system cannot find the file specified."

I have downloaded Visual Studio 2017 RC. I create a default ASP.NET Core MVC web application (no authentication), press F5 to run it inside IIS Express and I get this message:
The .csproj is a default one:
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.0</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
</PropertyGroup>
<PropertyGroup>
<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink.Loader" Version="14.0.0" />
</ItemGroup>
</Project>
Running dotnet --version from the command line returns 1.0.0-preview4-004233.
I'm not sure if it's a valid thing to do, but if I change the output DLL's extension to exe and run it, I get a little bit more detail:
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
at System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit)
at System.AppDomain.GetTargetFrameworkName()
However, installing System.Runtime NuGet package in this version does not help.
I also have Visual Studio 2015 with .NET Core tools installed on the same machine, could it be an issue?
How do I run ASP.NET Core web apps from VS 2017?

Resources