Resource.Designer.cs: "Resource ... does not contain a definition for ..." - c#

today I updated the NuGet packages for our Android version (we are currently developing for Android and iOS).
After the updates I cannot build the Android version anymore. This is an issue I faced everytime after updating packes so far, but this time I can't solve this problem.
Usually restarting Xamarin or Reinstalling the NuGet packages helped.
I have 151 error messages like this one:
/Users/Username/Projects/MyAppName/Droid/Resources/Resource.designer.cs(118,118):
Error CS0117: >MyAppName.Droid.Resource.Attribute' does not contain a
definition for mediaRouteSettingsDrawable' (CS0117) (MyAppName.Droid)
Here are all the steps I already did trying to fix this problem (in this order):
Build --> Clean all
Uninstall every NuGet package from every project (Droid, iOS, SyncLibrary (own library for SQL server communication) and UITest)
Delete everything inside of file "Resource.Designer.cs"
Close Xamarin
Install every package in the SDK Manager for every version
Delete the packages folder of the solution
Delete content of /Users/Username/.local/share/Xamarin
Delete content of /Users/Username/.local/share/NuGet/cache
Start Xamarin
Add Newtonsoft.Json package to SyncLibrary
Add Android packages: only add the needed packages, let NuGet resolve dependencies (like Xamarin.Android.Support, Xamarin.GooglePlayServices etc.) on its own.
Installed packages (in this order):
Xamarin.Forms.......................................(2.2.0.45)
Xamarin.Forms.Maps...........................(2.2.0.45)
XLabs.Forms............................................(2.0.5782)
ZXing.Net.Mobile..................................(2.0.4.46)
Newtonsoft.Json....................................(8.0.3)
Xam.Plugin.Geolocator........................(3.0.4)
Build --> Clean all
Restart Xamarin
Build new: SyncLibrary (so there's no dependency error when trying to build the Android version)
Build new: Android version --> Error
I really don't know what to do anymore.
Any help / ideas are appreciated, thanks in advance.

Xamarin.Forms...(2.2.0.45)
XLabs.Forms.....(2.0.5782)
That's the point. The last stable Xamarin.Forms has some problems that may cause build errors when you're using XLabs or another library.
The only solution which I know is to use pre-release version of XLabs.Forms - 2.2.0-pre02.
In my case I updated XLabs packages and cleared/rebuild my solutions.
More info in XLabs issue tracker and Xamarin Bugzilla.

I've experienced similar errors, but didn't use XLabs.Forms. I saw, that you used ZXing.Net.Mobile also, as me - I've updated that to newest pre-release (in the time of writing: 2.1.0-beta1) and it also helpep.

I have the same problem with mine Xamarin solution
have you tried:
Exit Visual Studio
Deleting c:\Users\username\AppData\Local\Xamarin
Open the solution again
Compile, wait until it finishes completely.
Anyway, found this link, maybe it was useful:
Xamarin: Build action EmbeddedResource

Related

System.DllNotFoundException (denoting an unavailable 'libSkiaSharp.so') thrown when attempting to use the SkiaSharp library

The aforementioned exception is thrown at the line that reads svgImage.Load(filePath), where svgImage is declared as an object of type SKSvg and filePath is the string holding the path of the svg file to be opened, with the exception message 'libSkiaSharp.so assembly:<unknown assembly> type:<unknown type> member:(null)'.
I have the following SkiaSharp based NuGet packages installed: SkiaSharp(v2.80.1), SkiaSharp.Svg(v1.60.0), and SkiaSharp.Views.Forms(v1.68.3). I am using Xamarin.Forms(v4.5.0.495) and the installed SkiaSharp packages all correspond to the latest versions supported by the installed version of Xamarin.Forms.
As far as I know, the .so file extension corresponds to the Linux based runtime libraries, which are irrelevant in my case as I am using Visual Studio 2019 (16.6.3) on Windows.
Thanks in advance.
I have just started using the SkiaSharp library with Xamarin Forms and had this exact same error. I double-checked my NuGet configuration and realised I had only installed the SkiaSharp package for the common project (and not for the .Android and .iOS projects) - it now works fine.
For VS2019 the steps are:
Right click on the Solution in Solution Explorer
Click Manage NuGet Packages for Solution...
Select the SkiaSharp library from the "Installed" packages list on the left hand side
Tick the box next to all of the projects, select "Latest stable" version (2.80.1 at time of writing) and hit Install
I test on the Xamarin.Forms 4.5.0.495 with SkiaSharp 2.80.1, SkiaSharp.Svg 1.60.0, SkiaSharp.Views.Forms(v1.68.3). The code below works well.
var filePath = "";
SkiaSharp.Extended.Svg.SKSvg svgImage = new SkiaSharp.Extended.Svg.SKSvg();
svgImage.Load(filePath);
If you still have the error, uninstall the packages and reinstall it. Delete the bin and obj folder. Try to clean and rebuild.
As per this post (originally) posted not long ago before this question, there apparently are, as of the time of this writing, some bugs/issues in the 2.xx versions of SkiaSharp. Using the last release among the 1.xx versions (i.e. 1.68.3) of the SkiaSharp library resolves the issue at hand.

ANTLR4 runtime problem in visual studio 2019

I'm trying to get antlr working in VS. I’ve not touched VS for a very long time. I've added the AntlrVSIX extension per the Antlr online docs, this created a sample calculator project for me but I can't compile it (I uninstalled and reinstalled AntlrVSIX but it made no difference to the following problem).
VS complains “The type or namespace name 'Antlr4' could not be found (are you missing a using directive or an assembly reference?)” and points to the line “using Antlr4.Runtime.Misc;” (and lots more similar).
If I look in menu Tools:NuGet Package Manager:Manage NuGetPackages for Solution… it clearly shows Antlr4.Runtime.Standard present and installed (showing version 4.8.0).
I guess I have to add a reference to this dll to my project so I I right click on References:Add Reference... in Solutions Explorer but I can’t find it in any list, however I search.
There is a Browse button which I assume I could use to link to the DLL directly, so I’ve searched the disk, found the dll and linked to that. This now works in that all those errors go away, but this can’t possibly be the right way.
So how do you add a reference to it properly, using References:Add Reference...? VS knows it’s there, it displays it, but doesn’t let it be referenced like that because it won’t show it within VS via References:Add Reference...
On your specific question, yes, you don't want to add a reference to the dll. Instead, you need to add a "<PackageReference>" in the csproj for these dependencies. All this lives in Nuget.org. So, in VS2019, right click on a project in the Solution Manager, then look for "Manage Nuget packages" to add Antlr4BuildTasks and Antlr4.Runtime.Standard.
Note, I've been updating the Antlrvsix extension, but haven't made a release for 2 months, longer than my usual schedule, because the next version has a huge number of changes. I will be cutting version 8 in a week. The template in VS2019 was removed because it is old and out of date. It uses an ancient version of the Antlr4BuildTasks. Instead, use the Antlr4BuildTasks.Templates v8.1 to create a C# project from scratch. Please follow the directions here. You don't need to download the Antlr tool kit, Java, or set any environmental variables. You also don't even need to use VS2019. You only need Net Core 3.1 and to install Antlr4BuildTasks.Templates. Then, type "mkdir foo; cd foo; dotnet new antlr; dotnet restore; dotnet build; dotnet run" at a command-line shell to create a C# application with Antlr4. Once you create the application, you can modify that to what you need. If you start from a Net Standard or Net Core project that doesn't have Antlr yet, you will need to add in the project reference for Antlr4.Runtime.Standard 4.8 and Antlr4BuildTasks 8.1, add in all grammars, and driver to set up and call the parser--harder to do, but it can be done through VS, or you can edit the CSPROJ file more easily and faster. The Antlr4BuildTasks looks at your CSPROJ file and will see that Antlr4.Runtime.Standard 4.8 is referenced, then will use the correct version of the Antlr JAR file to generate the parser and lexer. Any questions, let me know.
I suggest you using Antlr4.CodeGenerator NuGet package, it's gonna generated all necessary files (visitors, listeners) to work with your grammar in antlr. Check out my article for the details, there is a link to Github repo with the solution that works in VS 2019.

Errors with an installed NuGet package

First, I develop a program with "Any CPU".
Setting is "32 bit priority" and Any CPU. because It was default.
after I finish development, No compile error.
then, I switch Platform x64 and re-compile.
VS2017 show lot of error all installed NuGet package.
I tried to remove folder "obj", "bin". but I can not resolve anything. There is 28 errors. All is class name that I installed with NuGet.
SHould I not switch this ?
Why VS2017 has so many trouble ? Is this normal ?
When I develop with win-form, There is no trouble when I change target x86,x64...
How to resolve this un-linked class ?
All must be work...
My Nuget package is UwpDesktop, InputSimulator.
Update 1: I tried to re-install NuGet. but it does not resolve.
Update 2: I give up to use "x64". but I tried to modify the setting "AnyCPU" for 64 bit. Now, I success to compile again with 64 bit setting. I am also disable to un-check "32bit priority" option too. but.. I still feel big pain with VS2017 development , haha, It's really.
I compared Project setting with
(A) Any CPU = build success, Output folder is bin\Debug\
(B) x64 in Project setting, Output folder is bin\x64\Debug\
Both is "same" Except output folder name.
Is it important ??
I can not understand Why VS2017 can not build.
I think , Main cause is NuGet installed path. I do not know it, because I am 2nd week to learn VS2017, UWP : )
Now, There is still problem,
If I switch back to "x64", I can not compile..
but I can compile "AnyCPU".
Looks like some manual setup is required for that package. I quote https://preview.nuget.org/packages/UwpDesktop/10.0.14393.3
"We are working on updating this package with the latest release. Meanwhile as a workaround please add the following winmds to your project..."
Perhaps you want to downgrade that package and install a previous version, or follow those steps to be able to use it.
First, Thank you Tetsuya, Leo, bradbury9 for many hint.
I resolve this issue by my self.
As Leo wrote , Here is solution.
NuGet will install the dll to the Debug folder by default
To build with "Release" , We have to copy necessary DLL from "Debug" to "Release".
and Sometime, We have to copy x64/Release , x86/Release folder too.

Install Nuget Package error "The path is not of a legal form"

When trying to install the NuGet Package RestSharp I get the error The path is not of a legal form and the package is not installed.
When installing from the console using Install-Package RestSharp, there are a lot of the following messages:
The item
C:\Users\myName\Source\Workspaces\Project\Solution\packages\RestSharp.105.1.0\lib\net35\RestSharp.dll
could not be found in your workspace, or you do not have permission to
access it.
This happens with the newly released Visual Studio 2015 (community edition).
Edit: If you have NuGet 3.0, then that's the problem. Just update NuGet and everything should work. The steps below apply to NuGet 3.0, which are painful and error prone. Don't go through such pain, choose the easy step, update your Nuget!
I updated to VS Express 2015 and since then i've been through some adventures.
TL;DR if you "disable" TFS (source control), you should be able to install the package. Then add the solution to source control again, but it caused me tons of problems.
So...
I see you have TFS. I have it too.
Also, I see you are getting the same error messages as me.
I tried to install LanguageExt (an awesome library for C# 6) and it failed when it tried to install one of its dependencies (System.Collections.Immutable).
If you want to go through all this things, please make a backup of your project folder.
This is what I did:
1 - Copied my solution folder to somewhere else.
2 - Opened the solution. VS smartly asked me to add it to source control, but I didn't want to.
3 - Tried to Install-Package LanguageExt
4 - Unexpected success!
5 - "Fine, let me just add it to the TFS source control again"
Here my journey started.
Since I have little experience with TFS, I got thousands and thousands of conflicts, files vanishing and appearing again, etc.
But after some work, I got it running.
And it was worth it.
But the solution isn't large, so, it was easy.
Had the same problem with the packages below, updated NuGet via "Tools -> Extensions and Updates -> Updates" to v.3.1.1.0 and now everything works again. Thanks!
Microsoft.Bcl
Google.Apis.Calendar.v3
RazorEngine
Sample error so more people can find this thread:
"Install-Package : The path is not of a legal form.
At line:1 char:16
+ Install-Package <<<< RazorEngine
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand"
Had a same problem with my VS 2015, I just added the reference via nuget by opening the same solution in VS 2013 and then reopened it back in VS 2015 for usual work.
I had this happen on version 3.5.0.1484 of the nuget package manager. In my case a merge from a dev branch altered a packages.config file to list a version of a package that was no longer present. Any attempt to use one of the package commands in the Package Manager Console after loading the solution failed with the The Path is not of a legal form. error. I ended up using the solution level gui to consolidate on the affected packages and that resolved the error. Likely I could have just reverted the packages.config file as well.
Please add an entry in package.config manully as given below and build the solution. This works for me.
I had the same issue in VS 2017, with another package (WPFLocalizeExtension).
The way to solve that was to delete .nuget folder from the project, then go to .csproj project file, and delete the following lines:
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
After that (and after trying all the existing solutions into the whole world), I rebuilded the project nad the program runs succesful and works perfect.
It's really incredible the bugs of nugget repository....you need some kind of magic to solve in each specific case, it's terrible.
Hope this solution helps anyone.

Error: Reference to type claims it is defined, but it could not be found

I have a solution with 3 projects:
ParsersBase, that defines an interface IParseRule
ParsersLibrary, that has a reference to ParsersBase and defines a class HtmlImageUrlParseRule : IParseRule
ParsersLibraryTest, that has a reference to ParsersBase and ParsersLibrary and defines a test class with some test methods
When I'm trying to build it, I get a warning:
Reference to type 'AVSoft.ParsersBase.IParseRule' claims it is defined in 'c:\Users\Tim\Dropbox\projects\Image Downloader\ParsersLibrary\bin\Debug\ParsersLibrary.dll', but it could not be found
Why is VS trying to find AVSoft.ParsersBase.IParseRule in ParsersLibrary.dll? ParsersLibraryTest has a reference to ParsersBase; it just doesn't make any sense.
Another way this could happen is if you're using several NuGet packages where one, probably central, package has been updated but some additional functionality packages haven't been.
To work through my recent example - the error was "Reference to type 'ConsumerSubscriptionConfigurator<>' claims it is defined in 'MassTransit', but it could not be found". This is because we had updated MassTransit from 2 to 3, but we had not updated some of the other optional packages (MassTransit.log4net and MassTransit.Autofac) to the same version number. It appears as if assembly redirection had kept everything working until we tried to use one more additional feature.
This error seems to cover a variety of scenarios. In my case, closing and re-opening Visual Studio was the trick. After restarting Visual Studio, I was able to build the project as expected.
I had a similar problem. The site was running a cached version of the dll and not the one I had deployed to the bin directory. I cleared the temporary asp.net folder contents and this solved the issue.
It was my fault, I had a ParsersLibrary project at the start and then renamed it to ParsersBase, but I didn't rename an assembly name, then I added a ParsersLibrary project again.
So, two projects had the same assembly name and it's not very good, is it? :) Assemblies overlap each other, so I have this error.
I had the similar problem: Reference to type 'Func<>' claims it is defined in 'mscorlib', but it could not be found. The problem was following: my solution had Target Framework = 3.5 and I added a reference to Microsoft.Practices.Prism v 4.0 which is built against the framework 4.0.
After changing target framework to 4.0 it worked
It looks like things are a bit easier now than they were before.
As other answer(s) have basically already stated, this error can result from an older version of the same NuGet package not having some of the newer types in it. While in production, this is generally managed through proper versioning, in development, you may end up reusing the same version number when making changes. And that's a likely place where this problem can arise.
To fix this, you can often just clear the cache by doing the following:
In Visual Studio, go to Tools > NuGet Package Manager > Package Manager Settings.
In the pop-up menu, navigate to NuGet Package Manager > General.
In the options on the right, click Clear All NuGet Cache(s).
I hit this exception today. The problem in my case was I had some.package v2.1installed in my host and some.package v2.3 installed in other projects. Update-Package on the host project to v2.3 fixed the issue.
I my case, I tried to test a WPF project with a .NET Core (3.1) test project which could not reference the needed WindowsBase.dll.
Updating/consolidating packages didn't help. Even a clean repo and a restart of Visual Studio didn't solve it for for me.
But rebooting did fix the problem!
#binki's comment helped me;
deleting all .vs, bin, and obj folders, and then reopening the project
ParsersLibraryTest needs to reference ParsersBase. The second part of the error should read "You must add a reference to assembly 'ParsersBase..."
I tried all of the above answers but none resolved my issue.
In the end, I checked in my latest code (GIT), then recloned the repository in a different location.
Not ideal, but at least problem solved.
I had the similar problem: Reference to type 'Func<>' claims it is defined in 'mscorlib', but it could not be found. I have a lib of .Net 4 that was referenced by a .Net 3.5 program. After upgrading both to 4.61 it worked.
Seems like Func<T> is missing in .Net 3.5 and just upgrading that sample app would have been enough.
Further exp: Someone had added a signature in the library project (.Net 4) that uses a Func<T> parameter. But the sample program (3.5) already existed and ran fine so far. But at time of recompilation a dependency of a dependency clashed. Because mscorelib-3.5 had been already loaded. All happens at compilation time.
The only way I could overcome this error was to force uninstall of all nuget packages related and then reinstalling them. Sad but true.
I've just struggled with this error for a while now and finally get around it.
This is how to re-produce it and how I fixed it.
The problem was:
The packages were referenced by Right clicked -> add refernece -> Browse (choose). Then were added again as NuGet packages.
The solution was:
Remove the added references.
Remove the installed packages from .csproj.
Re-install the required packages from NuGet package mangager.
Close Visual Studio and re-open it.
Clean Project.
Build Project.
Note: If you couldn't remove the referenced files (no Remove option on right click) try close Visual studio and re-open it. Or delete or move the dll that were referenced then try again.
For me, I had chosen incorrect project, I was creating a class library project, I had to chose "Class Library (.Net framework)" but I had chosen "Class Library (.Net standard)"
Replacing the same resolved the issue.
The problem was following: my solution had Target Framework = 3.1 and I added a reference to Microsoft.EntityFrameworkCore.SqlServer v 2.0 which is built against the framework .
I had this problem with one of my library projects inside of a solution, after I switched from .NET Framework to .NET Standard. Eventually I just removed the project reference and added it again inside the application project that was reporting the problem. Oddly enough, the only thing that changed was project GUID switching to lower case from the previous upper case.

Categories