Xamarin Forms iOS build fails with Missing image - xamarin.forms

Visual Studio 2019 on Windows.
When I try and compile / debug the iOS project, I get an error reporting that an Asset image is missing. However, the named image is not part of the project - but something must be referencing it somewhere?
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\iOS\Xamarin.Shared.targets(398,3): error : File not found: /Users/gordon/Library/Caches/Xamarin/mtbs/builds/MyApp.iOS/660bf49bafcd3b0726d86bbdc8f9f98e66796d37cc48d5b91f8344eb1954729b/Assets.xcassets/icon_load.imageset/icon_load#2x.png
In the Asset Catalog, "Icon_Load" has an image called "icon_load#2.png" (plus others), I cannot find any reference to an image called "icon_load#2x.png" in any file within the solution.
I don't work on the image assets, so don't know the history of the files added, etc.

Related

NSBundle.MainBundle.PathForResource returns null for png image included in the Resources folder

I have a Xamarin.Forms class library project that I refer to in a Xamarin.Forms application project. In the iOS project of the class library, I have included a png image in the Resources folder and set its "Build Action" to BundleResource.
When I try to load this image file in the library project using the below code, I get null value.
string imagePath = NSBundle.MainBundle.PathForResource("ImageFileName", "png");
I had also tried setting the "Copy To Output" property of the image file to all available values (Do not copy, Copy always, Copy if newer). No matter which value is set, the path is returned as null.
I am using the iOS 15.0 simulator. I navigated to the bundle location of the application in the simulator's location in the Mac. I could not see the image file in the application bundle.
Is there any solution to this problem?

ASP.NET Publishing Web App Copying File Error When the File Has Already Been Deleted

I'm having a very peculiar issue in Visual Studio when trying to publish my MVC Web App on IIS, Windows 10. It is trying to copy a file that no longer exists in my solution. This is the error:
Severity Code Description Project File Line Suppression State
Error Copying file obj\Release\AspnetCompileMerge\Source\Views\Demo\File.cshtml to obj\Release\Package\PackageTmp\obj\Release\AspnetCompileMerge\Source\Views\Demo\File.cshtml failed. Could not find file 'obj\Release\AspnetCompileMerge\Source\Views\Demo\File.cshtml'. Solution 0
This file does not exist anywhere in my solution so I am unsure as to why it's trying to copy this file. I've tried restarted Visual Studio, cleaning and rebuilding my solution, deleting the .vs folder, but all of this has been for naught.
Solution 1
After you deleted file from folder (Not in the visual studio) usually become this error message. the reason for your "projectname.CSPROJ" file already recorded your deleted file reference
Eg : <Content Include="Views\home\Index.cshtml" />
Then you can to delete that reference from in your "projectname.CSPROJ"
Solution 2
if you can see file in the project, You can right click on the file and Exclude file from the project
after that you can publish your project without error
I am using VS 2019 and was getting the same error.
For me the reason seems to be the solution location. The file path was exceeding 200 chars.
After I copied the solution in c: drive it started working for me.
Try,
Right Click -> App_Data -> Click Exclude from Project.....
If you get an error like this it's better just to migrate your project to a new solution, that's what I did.

Visual Studio: Payload contains two or more files with the same destination path

I am suddenly receiving a strange build error on my UWP (Xamarin Forms) project which uses Akavache SQLite:
Payload contains two or more files with the same destination path 'SQLitePCLRaw.batteries_v2.dll'. Source files:
C:\Users\User\.nuget\packages\SQLitePCLRaw.bundle_e_sqlite3\1.1.8\lib\uap10.0\SQLitePCLRaw.batteries_v2.dll
C:\Users\User\.nuget\packages\SQLitePCLRaw.bundle_green\1.1.2\lib\uap10.0\SQLitePCLRaw.batteries_v2.dll
I don't really know what I did to trigger this; the only thing I know I changed between the time it did not work and the time it did is to associate the project with a store app package...
The UWP project is referencing two other projects, the head xamarin forms project, and a separate core library with other shared mobile components. both have reference to and use the Akavache library, and I do see that dll referenced in all three of the projects.
I tried changing the Copy Local to False for this batteries_v2.dll but that didn't fix it. I also tried cleaning the project and also manually deleting my bin/obj folders but that also didn't help...
what the heck did I do?

Unable to load DLL sqlite3 in Universal Windows App running on Mobile

I am developing a UWP. I am using the sqlite-net-pcl library. After upgrading my Application from RC to RTM , I got a runtime error - sqlite3.dll could not be found - if it runs on a Mobile emulator or a device. It worked prefectly after I added a reference to C++ 2013 Runtime Package and I ran it in Local Machine.
Exception Message:
Message "The type initializer for 'SQLitePCL.raw' threw an
exception." string
The innerexception message:
{"Unable to load DLL 'sqlite3': The specified module could not be
found. (Exception from HRESULT: 0x8007007E)"} System.Exception
{System.DllNotFoundException}
Of course I could not add a referece to 'Sqlite for Universal App Platform' because I am geting the following error
Severity Code Description Project File Line Error Payload contains
two or more files with the same destination path 'sqlite3.dll'. Source
files: C:\Program Files (x86)\Microsoft
SDKs\UAP\v0.8.0.0\ExtensionSDKs\SQLite.UAP.2015\3.8.11.1\Redist\Debug\ARM\sqlite3.dll
C:\Users\sMavrikis.nuget\packages\SQLitePCL.raw_basic\0.7.1\build\native\sqlite3_dynamic\winrt81\arm\sqlite3.dll TestApp1
Add a reference to 'SQLite for Universal App Platform'
This will trigger the error:
Payload contains two or more files with the same destination path 'sqlite3.dll'.
This error occurs because of different version of sqlite3.dll in both the locations marked by the error.
Resolve this error by simply copying
C:\Program Files (x86)\Microsoft SDKs\UAP\v0.8.0.0\ExtensionSDKs\SQLite.UAP.2015\3.8.11.1\Redist\Debug\ARM\sqlite3.dll
to
C:\Users\%USERNAME%\.nuget\packages\SQLitePCL.raw_basic\0.7.1\build\native\sqlite3_dynamic\winrt81\arm\sqlite3.dll
overwriting existing file.
Rebuild your project. It should compile now.
If you look at the two conflicting locations, one seems to be coming from a more official Microsoft extension for UWP, while the second is coming from a nuGet package.
When I encountered this error, I needed the functionality of the nuGet package, so I decided to keep it and drop the other reference. I right clicked on the project in the solution explorer and went to Add->Reference and then unchecked the reference to SQLite. Seemed less error prone than copying the file from one location to the other to me.
I was getting the same error messages. I had started by using SQLite-PCL which also required SQLite for Universal App Platform as a reference. Later I switched to SQLite.Net-PCL. That is when I got those errors. In researching a solution I found this page. It worked for a bit. Eventually I removed the Reference to SQLite for Universal App Platform and the errors went away.
late reply, but had the issue now; What fix it for me was to do Nuget Package update on all the project in the solution as one of the packages was still using the old reference and was pulling through to the Running project referencing the other project that was out of date.
I fixed a similar issue by selecting x64 or arm in the compiler configuration.
Error Payload contains two or more files with the same destination path 'e_sqlite3.dll'. Source files:
C:\Users\xleon.nuget\packages\SQLitePCLRaw.lib.e_sqlite3.v140\1.1.0\runtimes\win10-arm\native\e_sqlite3.dll
C:\Users\xleon.nuget\packages\sqlitepclraw.lib.e_sqlite3.v140\1.1.0\runtimes\win10-x86\native\e_sqlite3.dll
but this, of course, won´t allow you to run the emulator
Right-Click on the UWP Project and choose Properties.
And make sure the Solution Platform target matches the Project Platform target.
If they are different you will get the build error about copying files to the same destination with the same name (but different target platforms).
I managed to solve the disparity by putting a conditional in the UWP .csproj for including the SQLite dll
<SDKReference Include="SQLite.UWP.2015, Version=3.19.3" Condition="'$(Configuration)'=='Debug'">
<Name>SQLite for Universal Windows Platform</Name>
</SDKReference>
I needed to run with the UWP version for debugging, else my XAMl designer would blow up with "Can't find SQLite.dll..."

SQLite - System.Data.SQLite.2012 empty

I've downloaded sqlite-netFx-source-1.0.94.1.zip from SQLite website.
However, when I opened the SQLite.NET.2012.sln and noticed that the project System.Data.SQLite.2012 was empty, none of the source files (eg. SQLiteConnection.cs) was included in the project. (These files did exist in the file system but they are not included in any project of the solution.) The project can be built successfully and the System.Data.SQLite.dll could be generated. Not sure where did its content come from.
I was totally confused that how this could happen? Can any body help me? I want to modify the SQLiteConnection class and recompile the System.Data.SQLite.dll. Thanks.
There must be something missing from SQLite source code for the Visual Studio 2012 to parse the csproject file correctly.
After manually change the csproject file's xml content. I've successfully included the files into the project and built successfully. The DLL generated can be used then.

Resources