I've installed a NuGet-package required to run som code to create QR-codes. The package conflicts with system.drawing.common
Error CS0433 The type 'PixelFormat' exists in both 'CoreCompat.System.Drawing, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c0a7ed9c2333b592' and 'System.Drawing.Common, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
I'm trying to solve it like this:
using PixelFormat = CoreCompat.System.Drawing;
Allthough it throws an error:
Error CS0246 The type or namespace name 'CoreCompat' could not be found (are you missing a using directive or an assembly reference?)
Obviously Visual studio knows it's there somehow thoug since otherwise there would not be a conflict.
I've tried reinstalling all related NuGet-packages.
How would i go about solving this?
CoreCompat is an old library built to provide a System.Drawing compatible API that would work in Core, as originally System.Drawing was not supported. Since that time, Microsoft has released System.Drawing.Common, which is its own Core-compatible System.Drawing replacement API. Somehow, you have references to both in your project.
If your QR code library is using CoreCompat, you should really file an issue with that project to ask them to update the dependency to System.Drawing.Common. Or, you can make the change yourself and submit a pull request. Otherwise, or until it's corrected, you may need to find a different library to use.
It's possible the dependency is coming from somewhere else, as well. Check your own projects to ensure you're not bringing that in. Ultimately, you're simply going to have to do a little research here and see where CoreCompat is coming from and get rid of that.
Related
I'm using these pacakges:
PackageReference Include="Polly" Version="7.2.2"
PackageReference Include="Polly.Caching.Memory" Version="3.0.2"
I have a testproject that uses these packages and the code works.
When I try to integrate my code in an existing application with lots of other nuget packages, suddenly I get a TypeLoadException.
The method TryGet in the type Polly.Caching.Memory.MemoryCacheProvider from the assembly Polly.Caching.Memory, Version=3.0.0.0, Culture=neutral, PublicKeyToken=c8a3ffc3f8f825cc doesn't have an implementation.
I have been checking everything, but I can't find the cause of this.
The versions of Polly and Polly.Caching.Memory are aligned across all projects involved.
In the bin folder the correct version appears.
I looked at the code of the assembly and the code has an implementation for TryGet
Any suggestion on what I can do to further investigate this?
The packages were all correctly configured.
I got on the right track when I saw that the method was returning a tuple.
I figured that perhaps this second application was not using the correct versions of the same packages.
I changed :
<HintPath>..\Solutions\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
To
<HintPath>..\Solutions\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
Bingo!
If I:
Create a new C# query in LINQPad 6.
Add the System.ServiceModel.Http NuGet package or another package that references it.
Try to instantiate a class from the System.ServiceModel namespace, for example System.ServiceModel.BasicHttpBinding.
Leading to the following .linq file:
<Query Kind="Expression">
<NuGetReference>System.ServiceModel.Http</NuGetReference>
</Query>
new System.ServiceModel.BasicHttpBinding()
Then I get a compile error:
CS0433 The type 'BasicHttpBinding' exists in both 'System.Private.ServiceModel, Version=4.7.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System.ServiceModel.Http, Version=4.7.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
If I create a project in Visual Studio and add the same NuGet package and code, I do not get this error.
According to the C# Language reference for the error, it should be possible to resolve by using the -reference compiler option or by not referencing one of the assemblies. However, I can't seem to find a way to use this compiler option in LINQPad, nor can I find any way to remove the assembly reference to System.Private.ServiceModel.
How can I fix the error?
This is a bug in LINQPad, triggered by an obscure scenario. The System.Private.ServiceModel package contains a lib folder with an assembly which is required at runtime, and a ref folder with a underscore.underscore file which indicates that no assemblies should be referenced by the compiler. Because LINQPad finds no reference assemblies, it feeds the compiler the assembly in the lib folder, which causes the error.
I've got a fix ready and regression tests are currently running. The fix will likely make it into the 6.11.2 beta build, which should be released in a day or two.
I recently took a legacy WCF project with Entity Framework 4 and upgraded it to EF6 and .NET 4.0. I took the legacy Silverlight client project and upgraded as well. Problems started to arise when I added a new service reference to the upgraded WCF service. The code generated in the service reference has conflicts and will not compile.
My initial problem is that both Microsoft.Data.Services.Client and System.Data.Services.Client are part of the references…
CS0433 The type 'EntitySetAttribute' exists in both
'Microsoft.Data.Services.Client, Version=5.6.4.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' and 'System.Data.Services.Client,
Version=5.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
This surprises me even more when I look at the generated code, References.cs, that fails. The usage is fully qualified.
[global::System.Data.Services.Common.EntitySetAttribute("myTable")]. Apparently both assemblies use the exact same namespace.
If I remove Microsoft.Data.Services.Client I get:
Error CS1061 'myEntities4' does not contain a definition for
'DefaultResolveType' and no extension method 'DefaultResolveType'
accepting a first argument of type 'myEntities' could be found (are
you missing a using directive or an assembly reference?)
If I remove System.Data.Services.Client I get:
Could not load file or assembly 'System.Data.Services.Client,
Version=5.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or
one of its dependencies. The system cannot find the file specified.
This error is found in the XAML of a UserControl that uses a RadDataServiceDataSource.DataServiceContext.
I have spent quite a few hours trying several different paths including:
Getting older versions of Microsoft.Data.Services.Client from NuGet.
Using only one of the references, as mentioned above.
Changing the references in the WCF service before adding the Service Reference in the client.
Attempting advanced options when adding the Service Reference
Reuse all type from assemblies.
Reuse types in specified referenced assmeblies.
I have read the following posts, but they did not help:
Microsoft.Data.Services.Client.dll vs System.Data.Services.Client.dll
WCF error: Need to exclude all but one of the following types. Only matching types can be valid references
Project does not build after updating a service reference
I'm now considering building a new WCF and Web project to work around these issues. This should be an lengthy undertaking as well, and hopefully not a red herring.
Is this an artifact of upgrading from older versions of Silverlight, WCF, Entity Framework, or .NET in general? Please help me if you know what this is, or you have seen this before. A complete rewrite of the project to another platform is not an option unfortunately.
you can use this code :
EFContext.Configuration.ProxyCreationEnabled = false;
EFContext.Configuration.LazyLoading = false;
I've installed Migrator.NET using NuGet but when I attempt to run a migration using MSBuild I get the following error. I see that its having trouble accessing the Migrator.Framework assembly but I am unsure as to why or where specifically I need to put the DLL in order to get it to run.
C:\Users\Cody\src\App\App.Migrations\App.Migrations.csproj(64,5): error MSB4062: The "Migrator.MSBuild.Migrate" task could not be loaded from the assembly C:\Users\Cody\src\App\App.Migrations..\packages\MigratorDotNet.0.9.0.33276\tools\Migrator.MSBuild.dll.
Could not load file or assembly 'Migrator.Framework, Version=0.0.0.0, Culture=neutral, PublicKeyToken=3b3586e9632ecfce' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
Does anyone have any insight? I've spent far too long fiddling with this.
It turns out the issue was in fact that it was looking for version 0.0.0.0. I downloaded the project and recompiled the Migrator.Framework binary as version 0.0.0.0 as a quick fix. The real solution is recompiling Migrator.MSBuild.dll to look for the proper version of Migrator.Framework.
I'll see if this was a one-off error or if I can reproduce it, and submit it as a bug to the Migrator.NET team if it is in fact a bug with the NuGet package.
So, when I drag in Scintilla to my C# form, and try to run it, I get the error:
The type or namespace name
'ScintillaNet' could not be found (are
you missing a using directive or an
assembly reference?)
The error appears to be coming from the designer for Form1.
I also get the warning (but not error):
The referenced assembly "ScintillaNet"
could not be resolved because it has a
dependency on "System.Design,
Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" which
is not in the currently targeted
framework
".NETFramework,Version=v4.0,Profile=Client".
Please remove references to assemblies
not in the targeted framework or
consider retargeting your project.
So, I can't run my program...
What's wrong, and how do I fix it? I've installed scintilla just like how the directions for it suggested...
I was also experiencing this error (although I am hosting in WPF not WinForms). It was caused by Visual Studio 2010 defaulting the project to .Net 4.0 Client profile rather than the full .Net 4.0 profile.