I have a .net standard 2.0 library that I want to use to access the registry via the windows compatibility pack (if the OS its running on is Windows)
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Console.WriteLine("On windows.");
var dropFolder = Microsoft.Win32.Registry.GetValue(keyName: $#"{userRoot}\{subkey}", valueName: "DropFolder", defaultValue: #"C:\somepath");
Console.WriteLine($"Drop folder is {dropFolder}");
}
This crashes with an exception
Managed Debugging Assistant 'BindingFailure' : 'The assembly with
display name 'Microsoft.Win32.Registry' failed to load in the 'Load'
binding context of the AppDomain with ID 1. The cause of the failure
was: System.IO.FileNotFoundException: Could not load file or assembly
'Microsoft.Win32.Registry, Version=4.1.1.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The
system cannot find the file specified.'
I have installed the Windows Compatibility nuget package into my .net standard project. I have also tried installing the Microsoft.Win32.Registry nuget package.
The error perists.
If I comment out the lines
var dropFolder = Microsoft.Win32.Registry.GetValue(keyName: $#"{userRoot}\{subkey}", valueName: "DropFolder", defaultValue: #"C:\somepath");
Console.WriteLine($"Drop folder is {dropFolder}");
It works fine.
I am referencing the .net standard library from a .net framework library so no option to go to .net core.
The .dot net standard cs proj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Windows.Compatibility" Version="2.0.0" />
<PackageReference Include="MQTTnet" Version="2.8.2" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="RabbitMQ.Client" Version="5.1.0" />
</ItemGroup>
</Project>
For the missing binary to be included in the output of your .NET Framework project, you should also install the Microsoft.Windows.Compatibility package in this project. Or at least install the Microsoft.Win32.Registry package.
Related
I'm trying to publish this Maui project which targets Android 10.
I keep getting the following errors:
dotnet publish -f:net6.0-android -c:Release /p:AndroidSigningKeyPass=blah
MSBuild version 17.3.0+92e088760 for .NET Determining projects to
restore... C:\Program
Files\dotnet\sdk\6.0.400\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targe
ts(90,5): error : NETSDKZZZZ: Error getting pack version: Pack
'Microsoft.Android.Ref.29' was not present in workload m anifests.
[C:\git\StockTrackMauiGui\StockTrackMauiGui\StockTrackMauiGui.csproj]
C:\Program
Files\dotnet\sdk\6.0.400\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targe
ts(90,5): error : NETSDKZZZZ: Error getting pack version: Pack
'Microsoft.Android.Runtime.29.android-arm' was not present in
workload manifests.
[C:\git\StockTrackMauiGui\StockTrackMauiGui\StockTrackMauiGui.csproj]
C:\Program
Files\dotnet\sdk\6.0.400\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targe
ts(90,5): error : NETSDKZZZZ: Error getting pack version: Pack
'Microsoft.Android.Runtime.29.android-arm64' was not pre sent in
workload manifests.
[C:\git\StockTrackMauiGui\StockTrackMauiGui\StockTrackMauiGui.csproj]
C:\Program
Files\dotnet\sdk\6.0.400\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targe
ts(90,5): error : NETSDKZZZZ: Error getting pack version: Pack
'Microsoft.Android.Runtime.29.android-x86' was not prese nt in
workload manifests.
[C:\git\StockTrackMauiGui\StockTrackMauiGui\StockTrackMauiGui.csproj]
C:\Program
Files\dotnet\sdk\6.0.400\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targe
ts(90,5): error : NETSDKZZZZ: Error getting pack version: Pack
'Microsoft.Android.Runtime.29.android-x64' was not prese nt in
workload manifests.
[C:\git\StockTrackMauiGui\StockTrackMauiGui\StockTrackMauiGui.csproj]
Here's the content of my csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0-maccatalyst;net6.0-android29.0</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
<RootNamespace>StockTrackMauiGui</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<!-- Display name -->
<ApplicationTitle>StockTrackMauiGui</ApplicationTitle>
<!-- App Identifier -->
<ApplicationId>com.kerry.stocktrackmauigui</ApplicationId>
<ApplicationIdGuid>FE258B43-CAF4-425D-94F2-1ED061D420C3</ApplicationIdGuid>
<!-- Versions -->
<ApplicationDisplayVersion>0.79.5</ApplicationDisplayVersion>
<ApplicationVersion>5</ApplicationVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">29.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
<ContentSQLiteInteropFiles>true</ContentSQLiteInteropFiles>
<CopySQLiteInteropFiles>false</CopySQLiteInteropFiles>
<CleanSQLiteInteropFiles>false</CleanSQLiteInteropFiles>
<CollectSQLiteInteropFiles>false</CollectSQLiteInteropFiles>
<FileVersion>0.79.5.0</FileVersion>
<AndroidSigningKeyStore>myapp.keystore</AndroidSigningKeyStore>
<PlatformTarget>AnyCPU</PlatformTarget>
<TargetPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">29</TargetPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-android|AnyCPU'">
<EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk>
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyAlias>key</AndroidSigningKeyAlias>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-android|AnyCPU'">
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyAlias>key</AndroidSigningKeyAlias>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-ios|AnyCPU'">
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyAlias>key</AndroidSigningKeyAlias>
<AndroidPackageFormat>apk</AndroidPackageFormat>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-ios|AnyCPU'">
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyAlias>key</AndroidSigningKeyAlias>
<AndroidPackageFormat>apk</AndroidPackageFormat>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-maccatalyst|AnyCPU'">
<AndroidKeyStore>True</AndroidKeyStore>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-maccatalyst|AnyCPU'">
<AndroidKeyStore>True</AndroidKeyStore>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-windows10.0.19041.0|AnyCPU'">
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyAlias>key</AndroidSigningKeyAlias>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-windows10.0.19041.0|AnyCPU'">
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyAlias>key</AndroidSigningKeyAlias>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-android29.0|AnyCPU'">
<EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk>
<AndroidKeyStore>True</AndroidKeyStore>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-android29.0|AnyCPU'">
<AndroidKeyStore>True</AndroidKeyStore>
</PropertyGroup>
<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />
<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup>
<None Remove="appsettings.json" />
<None Remove="Resources\Splash\splashscreen.jpg" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
<!-- Splash Screen -->
<ItemGroup>
<MauiSplashScreen Include="Resources\Splash\splashscreen.jpg" Color="#194067" ReSize="true" BaseSize="512,512">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</MauiSplashScreen>
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="7.0.0-preview.7.22376.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.0-preview.6.22324.4" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageReference Include="Zebra.Printer.SDK" Version="2.15.2634" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\StockTrackMaui.Core\StockTrackMaui.Core.csproj" />
<ProjectReference Include="..\StockTrackMaui.Infrastructure\StockTrackMaui.Infrastructure.csproj" />
</ItemGroup>
<ItemGroup>
<MauiXaml Update="Views\Common\BinOrLocation.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\Common\Message.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>
</Project>
Here's the content of my AndroidManifest.xml file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.kerry.stockcountmauigui" android:versionCode="6" android:versionName="v0.79.5">
<application android:allowBackup="true" android:icon="#mipmap/appicon" android:roundIcon="#mipmap/appicon_round" android:supportsRtl="true" android:label="StockCount"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!--Coarse location is required for android 9 or lower, Fine location for android 11 or lower.-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!--Location for Sqlite database file to be on sdcard-->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- For discovery or to manipulate Bluetooth settings-->
<uses-feature android:name="android.hardware.bluetooth" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-sdk android:minSdkVersion="29" android:targetSdkVersion="29" />
</manifest>
I installed all of the Android 10 system images
I've run the following commands -- I tend to think ZScaler or Beyond Trust is blocking some internet traffic. Here's the command and the results:
dotnet workload list
Installed Workload Ids Manifest Version Installation Source
--------------------------------------------------------------------------------
android 32.0.448/6.0.400 SDK 6.0.400, VS 17.3.32825.248
maui 6.0.486/6.0.400 SDK 6.0.400
maui-maccatalyst 6.0.486/6.0.400 VS 17.3.32825.248
maui-android 6.0.486/6.0.400 VS 17.3.32825.248
maccatalyst 15.4.447/6.0.400 VS 17.3.32825.248
maui-ios 6.0.486/6.0.400 VS 17.3.32825.248
ios 15.4.447/6.0.400 VS 17.3.32825.248
maui-windows 6.0.486/6.0.400 VS 17.3.32825.248
I'm only targeting android 10 (SDK Platform 29)
I open a DOS window as administrator but Beyond Trust may or may not elevate when needed.
dotnet workload install maui
Inadequate permissions. Run the command with elevated privileges.
So I switch to my "supposedly local admin" account and run the same command
dotnet workload install android
Failed to update the advertising manifest microsoft.net.sdk.android: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.sdk.ios: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.sdk.maccatalyst: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.sdk.macos: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.sdk.maui: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.sdk.tvos: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.workload.mono.toolchain: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.workload.emscripten: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Installing pack Microsoft.Android.Sdk.Windows version 32.0.448...
Pack Microsoft.Android.Sdk.Windows version 32.0.448 is already installed.
Writing workload pack installation record for Microsoft.Android.Sdk version 32.0.448...
Installing pack Microsoft.Android.Ref.31 version 32.0.448...
Pack Microsoft.Android.Ref.31 version 32.0.448 is already installed.
Writing workload pack installation record for Microsoft.Android.Ref.31 version 32.0.448...
Installing pack Microsoft.Android.Runtime.31.android-arm version 32.0.448...
Pack Microsoft.Android.Runtime.31.android-arm version 32.0.448 is already installed.
Writing workload pack installation record for Microsoft.Android.Runtime.31.android-arm version 32.0.448...
Installing pack Microsoft.Android.Runtime.31.android-arm64 version 32.0.448...
Pack Microsoft.Android.Runtime.31.android-arm64 version 32.0.448 is already installed.
Writing workload pack installation record for Microsoft.Android.Runtime.31.android-arm64 version 32.0.448...
Installing pack Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-arm version 6.0.8...
Pack Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-arm version 6.0.8 is already installed.
Writing workload pack installation record for Microsoft.NETCore.App.Runtime.AOT.Cross.android-arm version 6.0.8...
Installing pack Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-arm64 version 6.0.8...
Pack Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-arm64 version 6.0.8 is already installed.
Writing workload pack installation record for Microsoft.NETCore.App.Runtime.AOT.Cross.android-arm64 version 6.0.8...
Garbage collecting for SDK feature band(s) 6.0.400...
Successfully installed workload(s) android.
I removed many lines of successfully installed packages due to hitting the 30000 character limit
dotnet workload install maui
Failed to update the advertising manifest microsoft.net.sdk.android: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.sdk.ios: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.sdk.maccatalyst: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.sdk.macos: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.sdk.maui: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.sdk.tvos: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.workload.mono.toolchain: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.workload.emscripten: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Installing pack Microsoft.Maui.Core.Ref.android version 6.0.486...
Pack Microsoft.Maui.Core.Ref.android version 6.0.486 is already installed.
Writing workload pack installation record for Microsoft.Maui.Core.Ref.android version 6.0.486...
Installing pack Microsoft.Maui.Essentials.Runtime.win version 6.0.486...
Pack Microsoft.Maui.Essentials.Runtime.win version 6.0.486 is already installed.
Writing workload pack installation record for Microsoft.Maui.Essentials.Runtime.win version 6.0.486...
Installing pack Microsoft.Maui.Graphics.Win2D.WinUI.Desktop version 6.0.403...
Pack Microsoft.Maui.Graphics.Win2D.WinUI.Desktop version 6.0.403 is already installed.
Writing workload pack installation record for Microsoft.Maui.Graphics.Win2D.WinUI.Desktop version 6.0.403...
Garbage collecting for SDK feature band(s) 6.0.400...
Successfully installed workload(s) maui android.
I removed many lines of successfully installed packages due to hitting the 30000 character limit.
Your assistance is much appreciated.
I am using Gembox to open, modify and save a xlsx file. Calling Save on the Excelfile causes a System.IO.FileNotFoundException.
The problem happens with our company serial key and with the free key.
Sample Code
using GemBox.Spreadsheet;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
var path = #"C:\code\GemboxTest\App.xlsx";
SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");
ExcelFile ef = ExcelFile.Load(path);
ExcelWorksheet ws = ef.Worksheets[0];
//ws.Columns[0].Cells[0].Value = 42;
ef.Save(path); // <--------------------------------- Crash!
}
}
}
Error message
Could not load file or assembly 'System.Security.Permissions, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
System.Security.Permissions, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
Stacktrace
at .(Stream , Byte[] , Int32 , Int32 , String )
at .(Stream )
at .(Stream )
at . ()
at .(Stream )
at .Dispose()
at . (Boolean )
at .Dispose()
at . ()
at .(Boolean )
at .Dispose()
at GemBox.Spreadsheet.XlsxSaveOptions.(ExcelFile , Stream , )
at GemBox.Spreadsheet.XlsxSaveOptions.Save(ExcelFile excelFile, Stream stream, String path)
at GemBox.Spreadsheet.SaveOptions.(ExcelFile , String )
at GemBox.Spreadsheet.ExcelFile.Save(String path, SaveOptions options)
at GemBox.Spreadsheet.ExcelFile.Save(String path)
at ConsoleApp.Program.Main(String[] args) in C:\code\GemboxTest\ConsoleApp\Program.cs:line 14
Versions
.NET Core 3.1 (also fails with 3.0)
GemBox.Spreadsheet Version=45.0.1131
Visual Studio 2019 (VisualStudioVersion = 16.0.29905.134)
Windows 10 pro 64bit
Sample csproj file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GemBox.Spreadsheet" Version="45.0.1131" />
</ItemGroup>
</Project>
Here the reply from Gembox support
Try adding "System.Security.Permissions" package reference to your ".csproj" file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GemBox.Spreadsheet" Version="45.0.1131" />
<PackageReference Include="System.Security.Permissions" Version="4.7.0" />
</ItemGroup>
</Project>
As an FYI, I believe that this package is only required for the
Console application on Windows. It's not required when you're saving
XLSX files with ASP.NET Core application on Windows or when you're
saving XLSX files with any .NET Core application on Linux.
It appears the package has a dependency on an assembly that isn't referenced or included.
Typically, a package author would reference their dependencies in their nuspec file for the Targetframework (each TargetFramework).
You can work around it by adding the latest System.Security.Permissions nuget package as a dependency to your project.
Update 1: Additionally
Looking at their example project github repo, I do see references to netcoreapp3.1 there.
I tested both netcoreapp3.1 and netcoreapp3.0, received the dependency package issue with Save, worked around it by adding it as a dependency (as this answer suggests). Gembox.Spreadsheet.Example
The example and usage of netcoreapp2.2 had no issues with missing dependencies of the package when attempting a Save.
Update 2
Removed reference to observed issue with Load mentioned in Update 1. It appears to be unrelated and probably a runtime and\or IDE issue I was experiencing.
Also, this issue was only tested and observed with a console application on windows platform.
I m working with N-tier architecture with .netcore 2.2
see how my project structure:
MainProject Version: how I m create the project(ASP.NET Core Web Application->Next->create->Empty(select the DropDown ASP.NET Core 2.2)
business logic project Version: how I m create the project(class library .net core)
data access project Version: how I m create the project(class library .net core)
model project Version: how I m create the project(class library .net core)
Error is:
Severity Code Description Project File Line Suppression State
Error NU1107 Version conflict detected for Microsoft.EntityFrameworkCore. Install/reference Microsoft.EntityFrameworkCore 3.1.2 directly to the project to resolve this issue.
projectname-> projectname.BusinessLogic -> projectname.DataAccess -> Microsoft.EntityFrameworkCore (>= 3.1.2)
projectname-> Microsoft.AspNetCore.App 2.2.0 -> Microsoft.EntityFrameworkCore (>= 2.2.0 && < 2.3.0). projectname
when I click on an error then this file display:
projectname.csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DMEBase.BusinessLogic\DMEBase.BusinessLogic.csproj" />
<ProjectReference Include="..\DMEBase.Model\DMEBase.Model.csproj" />
</ItemGroup>
</Project>
Only 1 error is generated in my project
how to solve this issue? help
NuGet Packages ScreenShot:
Write Click On Solution then I m going to Managenugetpackages->Consolidate->No Packages Found:
Downgrade entity framework core version as compatible core framework.
I tried to setup a .net core console application which uses EF core 2.0.0 and Redis.Core 1.0.3 (both are the current latest version).
Unfortunately if you try to put both into one application it won't even start. Even if you try to set a breakpoint right at the beginning or start debugging with Step into or Step Over doesn't help. All you get is this:
I think there happens some kind of type load exception or something similar. So far to reproduce the problem is quite easy with this project:
Project File (MyProject.csproj)
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Redis.Core" Version="1.0.3" />
</ItemGroup>
</Project>
Application (Program.cs)
using Microsoft.Extensions.Caching.Redis;
using Microsoft.Extensions.Options;
namespace MyApplication
{
class Program
{
static void Main(string[] args)
{
var cache = new RedisCache(Options.Create(new RedisCacheOptions()));
}
}
}
Anybody an idea or solution?
The problem is that
Microsoft.Extensions.Caching.Redis.RedisCache 1.0.3 depends on Microsoft.Extensions.Caching.Abstractions 1.0.3
Microsoft.EntityFrameworkCore 2.0.0 depends on Microsoft.Extensions.Caching.Abstractions 2.0.0
If you look at the Output Window, you will get:
TypeLoadException: Method GetAsync in type
Microsoft.Extensions.Caching.Redis.RedisCache from assembly
'Microsoft.Extensions.Caching.Redis, Version=1.0.3.0, Culture=neutral,
PublicKeyToken=adb9793829ddae60' does not have an implementation.
So: either wait until RedisCache gets updated to 2.0.0 or use EntityFrameworkCore < 2.0.0
I have following projects on solution and this works perfectly fine on my local.
However when I check code in Team service and create build it fails.
mainconsole.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
<PackageTargetFallback>portable-net45+win8</PackageTargetFallback>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.Portable.Compatibility" Version="1.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\business\business.csproj" />
<ProjectReference Include="..\portableextensibility\portableextensibility.csproj" />
<ProjectReference Include="..\portablelibrary\portablelibrary.csproj" />
</ItemGroup>
</Project>
Build tasks:
command line - tool dotnet, argument - restore
command line - tool dotnet, argument - build
Build fails:
d:\a\3\s\portablelibrary\portablelibrary.csproj(43,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\1.0.4\Microsoft\Portable\v4.5\Microsoft.Portable.CSharp.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
d:\a\3\s\portableextensibility\portableextensibility.csproj(42,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\1.0.4\Microsoft\Portable\v4.5\Microsoft.Portable.CSharp.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
C:\Program Files\dotnet\sdk\1.0.4\NuGet.targets(97,5): error : Unable to resolve 'd:\a\3\s\portableextensibility\portableextensibility.csproj' for '.NETCoreApp,Version=v1.1'. [d:\a\3\s\dotnetcompatibility.sln] C:\Program Files\dotnet\sdk\1.0.4\NuGet.targets(97,5): error : Unable to resolve 'd:\a\3\s\portablelibrary\portablelibrary.csproj' for '.NETCoreApp,Version=v1.1'. [d:\a\3\s\dotnetcompatibility.sln] Generating MSBuild file d:\a\3\s\mainconsole\obj\mainconsole.csproj.nuget.g.props. Generating MSBuild file d:\a\3\s\mainconsole\obj\mainconsole.csproj.nuget.g.targets. Writing lock file to disk. Path: d:\a\3\s\mainconsole\obj\project.assets.json Restore failed in 37.7 sec for d:\a\3\s\mainconsole\mainconsole.csproj.
Errors in d:\a\3\s\business\business.csproj
Unable to resolve 'd:\a\3\s\portablelibrary\portablelibrary.csproj' for '.NETStandard,Version=v1.1'.
Errors in d:\a\3\s\mainconsole\mainconsole.csproj
Unable to resolve 'd:\a\3\s\portableextensibility\portableextensibility.csproj' for '.NETCoreApp,Version=v1.1'.
Unable to resolve 'd:\a\3\s\portablelibrary\portablelibrary.csproj' for '.NETCoreApp,Version=v1.1'.
Since the solution contains PCL libraries which currently cannot be built using the dotnet cli, the project has to be built through msbuild instead of the dotnet based commands.
Here is the corrected configuration:
Build Definition
Queue options
Result