I'm trying to compile an uwp app but I get the following error:
Warning MCG : warning MCG0007: Unresolved P/Invoke method 'ntdll!RtlGetVersion' for method 'System.Int32 Microsoft.DotNet.PlatformAbstractions.Native.NativeMethods.Windows.RtlGetVersion(Microsoft.DotNet.PlatformAbstractions.Native.NativeMethods.Windows.RTL_OSVERSIONINFOEX)'. Calling this method would throw exception at runtime. Please make sure the P/Invoke either points to a Windows API allowed in UWP applications, or a native DLL that is part of the package. If for some reason your P/Invoke does not satisfy those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs.
The thing is that I can't find the origin, is there a way to debug this issue? Or how could I find the library that is causing the issue?
UPDATE: I attach a sample project that throws the same compilation error. If anyone could take a look. I'll be very grateful.
Sample project
UPDATE 2: I have an UWP app that uses the following nuget packages:
This app uses 3 .netstandard libraries.
The UWP app contains the following references.
<PackageReference Include="AdaptiveCards">
<Version>1.2.4</Version>
</PackageReference>
<PackageReference Include="MailKit">
<Version>2.4.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.AppCenter">
<Version>2.6.4</Version>
</PackageReference>
<PackageReference Include="Microsoft.AppCenter.Analytics">
<Version>2.6.4</Version>
</PackageReference>
<PackageReference Include="Microsoft.AppCenter.Crashes">
<Version>2.6.4</Version>
</PackageReference>
<PackageReference Include="Microsoft.Azure.Storage.Blob">
<Version>11.1.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.2.9</Version>
</PackageReference>
<PackageReference Include="Microsoft.Services.Store.Engagement">
<Version>10.1901.28001</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp">
<Version>6.0.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications">
<Version>6.0.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Animations">
<Version>6.0.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls">
<Version>6.0.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls.DataGrid">
<Version>6.0.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.UI.Xaml">
<Version>2.3.191211002</Version>
</PackageReference>
<PackageReference Include="Microsoft.Xaml.Behaviors.Uwp.Managed">
<Version>2.0.1</Version>
</PackageReference>
<PackageReference Include="MimeKit">
<Version>2.4.1</Version>
</PackageReference>
<PackageReference Include="MvvmLight">
<Version>5.4.1.1</Version>
</PackageReference>
<PackageReference Include="SQLitePCLRaw.bundle_green">
<Version>2.0.2</Version>
</PackageReference>
<PackageReference Include="SQLitePCLRaw.core">
<Version>2.0.2</Version>
</PackageReference>
<PackageReference Include="Win2D.uwp">
<Version>1.24.0</Version>
</PackageReference>
It uses 3 .netStandard libraries.
ServicesLibrary
<PackageReference Include="itext7" Version="7.1.9" />
<PackageReference Include="Microsoft.AppCenter" Version="2.6.4" />
<PackageReference Include="Microsoft.AppCenter.Analytics" Version="2.6.4" />
<PackageReference Include="Microsoft.Azure.Storage.Blob" Version="11.1.1" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.7.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Portable.BouncyCastle" Version="1.8.5.2" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.7.0" />
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="4.7.0" />
<PackageReference Include="System.ServiceModel.Http" Version="4.7.0" />
DataLibrary
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.0" />
<PackageReference Include="Z.EntityFramework.Extensions.EFCore" Version="3.0.31" />
<PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="3.0.31" />
<PackageReference Include="Z.Expressions.Eval" Version="3.0.11" />
SigningLibrary
<PackageReference Include="BouncyCastle.NetCore" Version="1.8.5" />
<PackageReference Include="System.Security.AccessControl" Version="4.7.0" />
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="4.7.0" />
<PackageReference Include="System.Security.Cryptography.Xml" Version="4.7.0" />
<PackageReference Include="System.Security.Permissions" Version="4.7.0" />
<PackageReference Include="System.Security.Principal.Windows" Version="4.7.0" />
The UWP references the ServicesLibrary and the DataLibrary, the ServicesLibrary references the SigningLibrary and the DataLibrary. That's the anatomy of the app that I'm trying to compile in release mode.
Thanks a lot for your help.
After all the suggestions, and trying to reproduce the compiler error. I find out that the Z.EntityFramework library was the one causing the issue. Looking at the logs all that I found was a reference to EntityFrameworkCore, related to the compiler error. But from that I started to remove libraries until I finally found the one that was causing the issue.
It's very hard and a bit frustrating finding the solution with such a cryptic message as MCG0007: Unresolved P/Invoke
Thanks for your help.
Related
I have a Blazor Server project and a WebApi project that i want to add into a .NET MAUI project.
All are in .NET 6. However, i get this error message when i build the solution.
Error NETSDK1082 There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'ios-arm64'. MobileApp C:\Program Files\dotnet\sdk\6.0.400\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets 430
When I remove the project reference from MAUI to the Blazor and WebApi projects I dont have this issue.
I suppose that there is a reference to these packages that is causing the issue:
<PackageReference Include="Font.Awesome" Version="5.15.4" />
<PackageReference Include="jose-jwt" Version="4.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.8" NoWarn="NU1605" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="6.0.8" NoWarn="NU1605" />
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.8">
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="6.0.8" />
<PackageReference Include="NETCore.MailKit" Version="2.1.0" />
<PackageReference Include="papercut" Version="2010.3.3.20130622" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="7.0.5" />
<PackageReference Include="Blazored.LocalStorage" Version="4.2.0" />
<PackageReference Include="Microsoft.Extensions.ApiDescription.Client" Version="6.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MudBlazor" Version="6.0.14" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="NSwag.ApiDescription.Client" Version="13.16.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers;
</PackageReference>
<PackageReference Include="System.Net.Http.Json" Version="6.0.0" />
<PackageReference Include="Font.Awesome" Version="5.15.4" />
I use a class library project called SharedLib that includes the WebApi and Blazor Server projects references, then in the MAUI project i reference the sharedLib project.
Then i would like to in the Pages / Index.razor access the Blazor Server Component.
I am trying to build a dotnet core project on a linux machine.
Build fails with the following error:
: error MSB4018: The "ResolveTargetingPackAssets" task failed
unexpectedly.
[/var/lib/jenkins/workspace/MyProject/MyProject/MyProject.csproj]
/usr/share/dotnet/sdk/3.0.103/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(264,5)
I don't know what to do, can someone please advise.
See csproj below.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.30" />
<PackageReference Include="Flurl.Http" Version="2.4.2" />
<PackageReference Include="Flurl.Http.Xml" Version="1.6.1" />
<PackageReference Include="LazyCache" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0" />
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="3.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="5.0.0-rc4" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="5.0.0-rc4" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUi" Version="5.0.0-rc4" />
<PackageReference Include="System.Data.SqlClient" Version="4.7.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.5.0" />
<PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="3.0.13" />
</ItemGroup>
<ItemGroup>
<Folder Include="Security\" />
</ItemGroup>
</Project>
I recently upgraded one of my ASP.NET Core applications from a net461 app to ASP.NET Core 2.0 app since the only thing that was holding me back in the past was System.Transactions (which is now supported).
After upgrading I get an error when accessing any function that is using the following:
protected static TransactionScope GetTransactionScope()
{
TransactionOptions transactionOptions = new TransactionOptions
{
IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted,
Timeout = TransactionManager.MaximumTimeout
};
return new TransactionScope(TransactionScopeOption.Required, transactionOptions);
}
Error:
Enlisting in Ambient transactions is not supported.
Based on my google research I saw a few open issues on GitHub related to this and they all say that upgrading System.Data.SqlClient to the latest pre-release will fix the issue.
I believe this fixed that issue, but caused another one. I am using Dapper v1.50.2 in my project and I think it is unable to use the pre-release version of System.Data.SqlClient because I am now getting the following error:
The type initializer for 'System.Data.SqlClient.SqlConnection' threw
an exception
Does anyone know how I can use Dapper and also get rid of this Ambient transactions error? I am not sure how System.Transactions was ported over when an error like this is occurring.
I've recently fixed this issue.
First, in your Web.csproj replace
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
with
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Antiforgery" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.ApplicationInsights.HostingStartup" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Core" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Facebook" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Google" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OAuth" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Twitter" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authorization.Policy" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.AzureAppServices.HostingStartup" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.AzureAppServicesIntegration" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.CookiePolicy" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.Internal" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.AzureStorage" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.Extensions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.Server.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Html.Abstractions" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Http.Extensions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.HttpOverrides" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Localization" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Localization.Routing" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.MiddlewareAnalysis" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.ApiExplorer" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Cors" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.DataAnnotations" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Json" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Xml" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Localization" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.Extensions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.RazorPages" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.TagHelpers" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.NodeServices" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Owin" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Razor" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Language" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Runtime" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.ResponseCaching" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.ResponseCaching.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.ResponseCompression" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Rewrite" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Routing.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.HttpSys" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Core" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Https" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Session" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.WebSockets" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.0.1" />
<PackageReference Include="Microsoft.CodeAnalysis.Razor" Version="2.0.1" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.0.0" />
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Redis" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Ini" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Xml" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.DiagnosticAdapter" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Abstractions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Composite" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Physical" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.EventSource" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.TraceSource" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Primitives" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.WebEncoders" Version="2.0.0" />
<PackageReference Include="Microsoft.Net.Http.Headers" Version="2.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.0.1" />
in this package references I removed all references on EntityFramework and SqlServer caching.
then, add reference to older System.Data.SqlClient
<PackageReference Include="System.Data.SqlClient" Version="4.3.0" />
Hope it helps!
I want to share my solution with the issue message:
The type initializer for 'Microsoft.Data.SqlClient.SqlConnection'
threw an exception.
Also the 'Microsoft.Data.SqlClient.SqlConnectionFactory' appeared in the issue.
This appears using Dapper or Microsoft.Data.SqlClient libraries.
Let me show you, I have two C# projects:
ConnectionToDB (Project used in 2.)
ASP.NET Core App
The problem that I found was that 1. had all the neccessary libraries/dependencies to work but for any kind of reason was not working. The problem was that the Microsoft.Data.SqlClient has to be inside 2. too to work. I don't know why but this may help to anyone.
Regards!
Use NuGet package manager and search for "System.Data.SqlClient", install the latest and the exception goes away.
I have a problem when I would like to deploy my app with docker.
I'm using ASP.Net Core with docker.
This an error message:
/usr/local/share/dotnet/sdk/1.0.4/Sdks/Microsoft.NET.Sdk/build/Microsoft.NET.Sdk.DefaultItems.targets(188,5):
error : Duplicate 'Content' items were included. The .NET SDK includes
'Content' items from your project directory by default. You can either
remove these items from your project file, or set the
'EnableDefaultContentItems' property to 'false' if you want to
explicitly include them in your project file. For more information,
see https://aka.ms/sdkimplicititems. The duplicate items were:
'wwwroot/_version.txt'
[/Users/xxxxxx/Projects/api-test/TestApi/TestApi.csproj]
Here's my csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1.1</TargetFramework>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
<UserSecretsId>0a7aa24d-009c-4d0b-b0fd-e8be397b0784</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoMapper" Version="6.0.2" />
<PackageReference Include="CoreCompat.System.Drawing" Version="1.0.0-beta006" />
<PackageReference Include="Google.Cloud.Storage.V1" Version="1.1.0-beta01" />
<PackageReference Include="HtmlAgilityPack.NetCore" Version="1.5.0.1" />
<PackageReference Include="MailKit" Version="1.16.1" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Xml" Version="1.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="1.1.0-beta2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="7.0.7-m61" />
<PackageReference Include="RazorLight" Version="1.1.0" />
<PackageReference Include="RazorLight.MVC" Version="1.0.4" />
<PackageReference Include="Serilog" Version="2.5.0-dev-00817" />
<PackageReference Include="Serilog.Extensions.Logging" Version="1.4.1-dev-10155" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="1.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="2.2.0-dev-00721" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="1.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="1.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="1.0.0" />
<PackageReference Include="WkWrap.Core" Version="1.0.2" />
<PackageReference Include="ZXing.Net" Version="0.15.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="SQL\" />
<Content Include="wwwroot\_version.txt">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
I think the problem is with a _version.txt file which is currently on the server (I can;t say that because I do not have an access) and It tries to duplicate it.
Would you mind to help me with that i
The .NET SDK includes Content items from your project directory by default, so wwwroot\_version.txt is already present in your project. Your project file is then attempting to add it again, which causes the error.
You can use Update instead of Include to cause the existing content item to be updated, rather than including it twice.
So, you just have to change
<Content Include="wwwroot\_version.txt">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
to
<Content Update="wwwroot\_version.txt">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</Content>
I am trying to read the body of a HTTP Request into a StreamReader in an MVC project.
I get this strange error and it's more than I know about .NET to solve it.
here's the detail from my CSPROJ:
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Formatters.Xml" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" 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.VisualStudio.Web.CodeGeneration.Design" Version="1.1.0" />
<PackageReference Include="NReco.Data" Version="1.0.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" />
I actually ran in to this bug yesterday after adding the comment to the question. The error is caused by a bug in resharper, you should still be able to build and run the solution still.
Make sure you are running the latest version of resharper and have cleared your cache for resharper too. If the problem still persists submit a bug report to JetBrains.