Xamarin "GenerateResourceDesigner" task failed unexpectedly and .dll file could not be found - c#

Hi I'm running a Xamarin PCL project thats deploying to all platforms including UWP windows 10 and windows 8.
I've just merged a branch on git and resolved some conflicts (not very well clearly) and i'm getting a few errors.
The first error:
The "GenerateResourceDesigner" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load assembly 'Vigour, Version=, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'Vigour.dll'
at Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(String fullName, ReaderParameters parameters)
at Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(String fullName)
at Xamarin.Android.Tuner.DirectoryAssemblyResolver.GetAssembly(String fileName)
at Xamarin.Android.Tasks.GenerateResourceDesigner.<Execute>c__AnonStorey0.<>m__0(String ass)
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at Xamarin.Android.Tasks.ResourceDesignerImportGenerator.CreateImportMethods(IEnumerable`1 libraries)
at Xamarin.Android.Tasks.GenerateResourceDesigner.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() Vigour.Droid
The second one:
I know this is a common problem and I've tried to un-tick and tick the build of each project in the solutions configuration.
I've also tried to remove the .vs/../.suo file to reset the project
However I've had no luck. I think that it might have something to do with the merger that involved changing the .csproj files.

Try to set API to 23 and then Rebuild the project it will solve the problem

Solution to this was to reinstall the xamarin forms for android and as #hvaughan3 said, deleting the bin and obj folder for all directories along with the packages.

In my case, I was getting error The "ResolveLibraryProjectImports" task failed unexpectedly. when I open a project downloaded from Xamarin.University on Windows 10 and the path for one of the files ends up being to long (longer than 260 characters). So, to solve my problem, I would copy the directory as shallow as possible, so instead working directly in the structure of downloaded project, I would copy deepest directory containing the project into my C:. Building would work then without an issue as the path to all files in the project got shortened.
So, say my downloaded structure from Xamarin.University is something like
C:\Users\me\Desktop\XAMARIN\XAMARIN CERTIFICATION\forms\xam300-advanced-cross-platform-development\Lab Materials\Part 03 Resources\Completed
I would copy the Completed folder into C and end up with much shorter path like:
C:\Completed

Related

Build a WPF application in VScode gave me error MSB4062

I am trying to perform a build on a WPF (.Net Core 3.1) in Visual Studio Code (not Visual Studio this time cause I need a more lightweight editor).Normally all my project can be built fine, but this WPF project gave me this following error:
C:\Program Files (x86)\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.
WinFX.targets(225,9): error MSB4062: The "Microsoft.Build.Tasks.Windows.MarkupCompilePass1" task could not be loaded from
the assembly C:\Program Files %28x86%29\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\tools\netcoreapp2.1\PresentationBuildTasks.dll. Could not load file or assembly 'C:\Program Files
%28x86%29\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\tools\netcoreapp2.1\PresentationBuildTasks.dll'. The system cannot find the path specified.
Confirm that the <UsingTask> 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. [E:\ui_wpf_test\ui_wpf_test.csproj]
The build failed. Fix the build errors and run again.
I heard that it has to do with MSbuild, but I dont know how to correctly fix this
I found a solution on GitHub. You have to replace the following line of %ProgramFiles(x86)%\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.WinFx.props:
<_PresentationBuildTasksAssembly Condition="'$(_PresentationBuildTasksAssembly)'==''">$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\tools\$(_PresentationBuildTasksTfm)\PresentationBuildTasks.dll'))</_PresentationBuildTasksAssembly>
Replace it with:
<_PresentationBuildTasksAssembly Condition="'$(_PresentationBuildTasksAssembly)'==''">$(MSBuildThisFileDirectory)..\tools\$(_PresentationBuildTasksTfm)\PresentationBuildTasks.dll</_PresentationBuildTasksAssembly>
This has eventually worked for me.
small bug. should be fixed in the new upcoming 3.1.103 instead of now 3.1.102.
Problem is the path Program Files (x86)' where(x86)is escaped to%28x86%29`, resulting in path not found.
temporary fix by just escaping the path:
Go to:
C:\Program Files (x86)\dotnet\sdk\3.1.102\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets
edit Microsoft.WinFx.props and use this _PresentationBuildTaskAssembly which has the Unescape for the path:
<_PresentationBuildTasksAssembly Condition="'$(_PresentationBuildTasksAssembly)'==''">$([MSBuild]::Unescape($([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\tools\$(_PresentationBuildTasksTfm)\PresentationBuildTasks.dll'))))</_PresentationBuildTasksAssembly>
It is possible that you can resolve it also by changing in visual studio the build to x64 instead of Any CPU/x86. With 64-bit this will use C:\Program Files\ instead of C:\Program Files (x86)\ and thus not have the 'bad' characters.

Xamarin.GooglePlayServices.Basement Fails Build

We have a cross platform mobile application solution built on top of Xamarin targeting Android and UWP. On every solution build there is roughly a 50/50 chance of receiving the following error:
Error : Could not load assembly 'Xamarin.GooglePlayServices.Basement,
Version=0.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't
exist in the Mono for Android profile? at
Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference
reference, ReaderParameters parameters) at
Xamarin.Android.Tasks.GetAdditionalResourcesFromAssemblies.<>c__DisplayClass37_0.b__1()
at System.Threading.Tasks.Task.InnerInvoke() at
System.Threading.Tasks.Task.Execute()
When receiving the error, if I turn around and immediately build the solution again the issue generally goes away. To further complicate the matter any of the Android projects in the solution can report this error, meaning it's not a single project giving me the problem. While annoying on my local machine, this introduces a lot of clutter when our CI-builds are constantly failing only to work when re-queuing the build.
I have attempted to remove and re-add the Xamarin nuget packages to the project. I've even deleted all the project files and created brand new ones, to no avail.
Any suggestions?

How to embed or-tools in a C# application?

I'm trying to follow the instructions at https://developers.google.com/optimization/introduction/installing.html#windows_binary so that I can use or-tools inside my C# application.
I'm stuck on the make all step. I am in the Developer Command Prompt, but this command says:
'make' is not recognized as an internal or external command,
operable program or batch file.
I tried downloading GNU make, but that fails also. make install says "no target", and a bare make says:
process_begin: CreateProcess(NULL, cl /EHsc /MD /nologo /D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS -nologo /O2 -DNDEBUG -DUSE_CBC -DUSE_CLP /D__WIN32__ /Iinclude\src\windows /DGFLAGS_DLL_DECL= /DGFLAGS_DLL_DECLARE_FLAG= /DGFLAGS_DLL_DEFINE_FLAG= /Iinclude /Iexamples -DUSE_GLOP -DUSE_BOP -c examples\cpp\costas_array.cc /Foobjs\costas_array.obj, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [objs\\costas_array.obj] Error 2
I also tried copying the DLLs from the bin folder directly into my project. I was able to compile against them by doing this, but when I tried to run it I got an error:
System.BadImageFormatException: 'Could not load file or assembly 'Google.OrTools, Version=5.1.6235.37215, Culture=neutral, PublicKeyToken=7a052e3db761d3be' or one of its dependencies. An attempt was made to load a program with an incorrect format.'
What am I missing?
Regarding the System.BadImageFormatException:
The OrTools binary format is provided in a 64bit dll.
Make sure, that your project is set to 64bit:
In Visual Studio you can check it out by right clicking on the Project --> Properties --> Build, Platform Target: This should be set to x64.
In case you have the same issue with web application, just enable 64 bits on IIS Express using Tools -> Options -> Projects and Solutions -> Web Projects -> Use the 64-bit version on IIS Express for web sites and projects
I was having this issue when using OR-Tools in a Web Application (it worked fine in a console application). I was getting:
System.BadImageFormatException HResult=0x8007000B Message=Could not load file or assembly 'Google.OrTools' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Using x64 didn't help, and Octopus was not building the project correctly either. The solution that worked for me was specifying which ASPNETCOMPILER to use (x64) in the project's .csproj :
<Project .... >
<PropertyGroup>
<AspNetToolPath>$(windir)\Microsoft.NET\Framework64\v4.0.30319</AspNetToolPath>
</PropertyGroup>

WebKit.NET with C# Project Runtime Exception

I have downloaded WebKit.NET 0.5-bin-cairo to work with an existing C# Project. I've included WebKitBrowser.dll and WebKit.Interop.dll as a reference to the module that requires it, as well as playing them directly in the debug/bin folder as directly by this tutorial.
I do not get any errors until I run the project and get an exception on this line in InitializeComponent() of the designer class.
this.webKitBrowser1 = new WebKit.WebKitBrowser();
The exception:
An unhandled exception of type 'System.ComponentModel.Win32Exception' occurred in WebKitBrowser.dll
Additional information: Failed to initialize activation context
I am building all the modules as 86x debug and my computer is 64 bit.
Any suggestions are appreciated as I've been playing around with this for multiple days.
I had encountered same issue. Three things were missing in my scenario.
manifest files: must be placed as all dlls are dynamically linked
VC++ must be installed on machine: In my case I used vc++2005 redistributable sp1.
Not only dlls/pdb/manifest you need to copy all the folders to root directory of executable
There is no correct packaging available yet for all files/folders of webkit.NET
And obviously project architecture should be x86 for all projects referencing webkit dlls
Have you tried:
WebKit.Net and OpenWebKitSharp Error: Failed to initialize activation context ? Namely to copy all the files from Core(not just the dlls) into your project /bin/release/ or /bin/debug/ folder?
quoted from the tutorial you followed:
Before we can run the application, WebKit.dll and it's dependencies must be present in the output directory. In Windows Explorer (or otherwise), copy all of the files from the WebKit .NET 'bin' directory to your project's output directory. For example, here is the listing of my output directory after copying:
D:\webkitdotnet\WebKitTest\WebKitTest\bin\Debug>ls
CFLite.dll icudt40.dll
JavaScriptCore.dll icuin40.dll
JavaScriptCore.resources icuuc40.dll
SQLite3.dll libcurl.dll
WebKit.Interop.dll libcurl.dll.manifest
WebKit.dll libeay32.dll
WebKit.resources libeay32.dll.manifest
WebKitBrowser.dll libpng13.dll
WebKitBrowser.dll.manifest libxml2.dll
WebKitBrowser.pdb libxslt.dll
WebKitTest.exe pthreadVC2.dll
WebKitTest.pdb ssleay32.dll
WebKitTest.vshost.exe ssleay32.dll.manifest
WebKitTest.vshost.exe.manifest zlib1.dll
curl.exe.manifest
You mentioned you only copied WebKitBrowser.dll and WebKit.Interop.dll over

Problem with error messages in solution

I have a solution with around 10 projects, I have not written any of this myself, but I'm going to take over a project here. The project that is the main project is based on WPF. When I try to run this project, I get the following compiler error:
The tag 'RoutingManagerView' does not exist in XML namespace 'clr-namespace:RoutingManager.Views;assembly=RoutingManager'. Line 29 Position 14. C:\Source\WSA\WsaClient\Views\MainView.xaml 29 14 WsaClient
Then, if I double click this error message, so that the xaml is opened, and the designer is loaded, the designer does not load, and I get 3 more error messages:
Unable to load the metadata for assembly 'WsaClient'. This assembly may have been downloaded from the web. See http://go.microsoft.com/fwlink/?LinkId=179545. The following error was encountered during load: Could not load file or assembly 'WsaClient' or one of its dependencies. The system cannot find the file specified. C:\Source\WSA\WsaClient\Views\MainView.xaml 1 1 WsaClient
Unable to load the metadata for assembly 'RoutingManager'. This assembly may have been downloaded from the web. See http://go.microsoft.com/fwlink/?LinkId=179545. The following error was encountered during load: Could not load file or assembly 'RoutingManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. C:\Steria\Forsvaret\P6088\Source\WSA\WsaClient\Views\MainView.xaml 1 1 WsaClient
The type 'Views:RoutingManagerView' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built. C:\Source\WSA\WsaClient\Views\MainView.xaml 29 14 WsaClient
I googled it, and many have suggested that this is because a DLL is locked since it originates from the internet. However in my condition, I do not have a DLL. It's complaining on two projects that are a part of the solution, WsaManager and RoutingManager. I got all the source code on a zip file on an usb pen, and I have extracted it to somewhere on my c drive, so there is no remote access of the code.
If anyone have had the same or similar problem earlier, I would highly appreciate any pointers here on how to resolve this.
EDIT
The last error message is given on this line in the XAML file:
<Views:RoutingManagerView DataContext="{Binding Dependency}"/>
And on the top of the XAML file, this is the import for the assembly:
xmlns:Views="clr-namespace:RoutingManager.Views;assembly=RoutingManager"
Resolve this by right clicking on the solution and choosing 'Rebuild Solution'
An additional point for other readers: if your projects builds successfully, but you get this error message while trying to load your view in the designer, make sure your assembly is x86 or Any CPU, because Visual Studio 2010 is a 32bit process and cannot load x64 assemblies in the designer.
To resolve this problem, I had to compile the projects one by one, starting from the project with no dependencies on other projects, and then working my way "up".
It seems that the Build all did not manage to do this properly automatically.
Try this, this was the only advice that worked for me:
Unable to load the metadata for assembly ''. This assembly may have been downloaded from the web. See http://go.microsoft.com/fwlink/?LinkId=179545.  The following error was encountered during load: Could not load file or assembly '' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
In WPF project to allow the project to load from remote source we have to enable it in the configuration file devenv.exe.config.
Step 1: Search the configuration file devenv.exe.config in your system. Usually it is located at
C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe.config
Step 2: Edit the configuration file. Add following line in the tag
<loadFromRemoteSources enabled="true" />
Step3: Restart your visual studio.
http://exacthelp.blogspot.cz/2012/02/unable-to-load-metadata-for-assembly.html
Unable to load the metadata for assembly 'WsaClient'. This assembly
may have been downloaded from the web. See
http://go.microsoft.com/fwlink/?LinkId=179545. The following error was
encountered during load: Could not load file or assembly 'WsaClient'
or one of its dependencies. The system cannot find the file specified.
C:\Source\WSA\WsaClient\Views\MainView.xaml 1 1 WsaClient
I run into same error: I can build and run my project, but I can not design XAML. I realized that it was local configuration issue because it's not replicable on my other machine (using same repository revision).
I started digging more and figured out that VS 2010 does not like # symbol in path. So error shows up when I have my sources in
C:\#projects\<my project>
After I moved them to
C:\projects\<my project>
Problem is gone.
I hope this will help to someone else.
I suspect the ..
The tag 'RoutingManagerView' does not exist in XML namespace 'clr-namespace:RoutingManager.Views;assembly=RoutingManager'. Line 29 Position 14. C:\Source\WSA\WsaClient\Views\MainView.xaml 29 14 WsaClient
.. error is causing a cascade of other errors. It looks like you're trying to create a RoutingManagerView from the namespace RoutingManager.Views in the assembly RoutingManager. However, it is not there. Make sure the class is visible to the outside world. Or try to clean and rebuild the solution and see on which project the first error occurs. Because if the projects are interdependent, an error in one project might cause reference errors in others.

Categories