Xamarin iOS, FileNotFound for Bundle Resources - xamarin.forms

I keep getting the error like this:
Error System.IO.FileNotFoundException: /Users/Nathaniel/Library/Caches/Xamarin/mtbs/builds/EagleEyePrism.iOS/7b66664107c017167463bbde19c6a2f4/obj/iPhone/Debug/optimized/upload_blue.png does not exist
File name: '/Users/Nathaniel/Library/Caches/Xamarin/mtbs/builds/EagleEyePrism.iOS/7b66664107c017167463bbde19c6a2f4/obj/iPhone/Debug/optimized/upload_blue.png'
at System.IO.File.Copy (System.String sourceFileName, System.String destFileName, System.Boolean overwrite) [0x00193] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-08/external/bockbuild/builds/mono-x64/mcs/class/corlib/System.IO/File.cs:111
at Xamarin.MacDev.Tasks.SmartCopyTaskBase.CopyFile (System.String source, System.String target, System.String targetItemSpec) [0x0002d] in <cd319828b05749ae9de0c80034a6d2bc>:0
at Xamarin.MacDev.Tasks.SmartCopyTaskBase.Execute () [0x000b6] in <cd319828b05749ae9de0c80034a6d2bc>:0 EagleEyePrism.iOS
It doesn't matter what file it is. If I remove upload_blue.png, it throws an error on the next Resource.
I have tried everything. I have deleted the Xamarin cache on the Mac, I've deleted AppData\Local\Xamarin on the PC, it simply will not compile.
If I set all the BundleResources to Embedded Resources, it will compile and run, but then none of my image collateral gets displayed.
I've scoured the internet for hours trying to solve this problem.
I'm running the latest XCode on the Mac, with MacOS Mojave, and Windows 10 with Visual Studio 2019 on the PC.

I solved it by disabling the Optimize PNG images option in the iOS Build Options

Related

DbContext.EnsureCreated() : ArgumentNullException only on RELEASE build

I am using microsoft ef-core and Sqlite database in my xamarin-forms app. My model is quite big, so I guess it's not a good idea to drop it here. I was working on the app for couple weeks and tested on my phone in Debug mode - everything worked perfectly.
But as soon as I've built RELEASE version - I got ArgumentNullException right on DbContext.EnsureCreated() call. I could find it using console output. So it says:
Value cannot be null. Parameter name: key
On DEBUG build my application works perfectly fine, and I have no build-dependent precompiler directives in my code also. Using Visual Studio 2017
Any thoughts or advices on what can I check?
UPD: here is stacktrace I got in Release:
I/mono-stdout(24851): TRACE: at System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) [0x00008] in <d029cac6f9824b0bb72d5eb6d48d11f3>:0
I/mono-stdout(24851): at System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in <d029cac6f9824b0bb72d5eb6d48d11f3>:0
I/mono-stdout(24851): at Microsoft.EntityFrameworkCore.Sqlite.Query.Internal.SqliteDateTimeAddTranslator..ctor (Microsoft.EntityFrameworkCore.Query.ISqlExpressionFactory sqlExpressionFactory) [0x000c5] in <7b7aa88a95d54aa786bada86edd4821a>:0
I/mono-stdout(24851): at Microsoft.EntityFrameworkCore.Sqlite.Query.Internal.SqliteMethodCallTranslatorProvider..ctor (Microsoft.EntityFrameworkCore.Query.RelationalMethodCallTranslatorProviderDependencies dependencies) [0x0001d] in <7b7aa88a95d54aa786bada86edd4821a>:0
I/mono-stdout(24851): at (wrapper managed-to-native) System.Reflection.MonoCMethod.InternalInvoke(System.Reflection.MonoCMethod,object,object[],System.Exception&)
I/mono-stdout(24851): at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x00005] in <d029cac6f9824b0bb72d5eb6d48d11f3>:0
The reason behind this is that the linker is being overly aggressive and it strips System.DateTime class from mscorlib assembly. The proper fix is, instead of preserveDateTimeMethods solution that you mentioned, to create a Custom Linker Configuration.
Create an empty file LinkDescription.xml
Add it to the OS-level project (Android, iOS, etc).
Set its build action to LinkDescription
Add System.DateTime to the linker block
Here's how:
<?xml version="1.0" encoding="UTF-8" ?>
<linker>
<assembly fullname="mscorlib">
<type fullname="System.DateTime" preserve="methods" />
</assembly>
</linker>
So, I've searched for hours and as soon as I've posted quiestion..
Looks like it's a ef-core bug - a linker problem working with DateTime types leading to attempt of adding null-key value to Dictionary.
Links to bug discussion:
https://github.com/dotnet/efcore/issues/14091
https://github.com/dotnet/efcore/issues/10963
I had this problem on my Android release build, so I've added line of code from one of comments on first discussion.
Added this line in my MainActivity.cs before Xamarin.Forms initialization:
var preserveDateTimeMethods = DateTime.Now.AddYears(1).AddMonths(1).AddDays(1).AddHours(1).AddMinutes(1).AddSeconds(1);
It resolved my problem. Hope it helps somebody.

Setting up .net site in IIS 8.5 (AWS)

My .net project (Any CPU) is referring to Oracle.dataaccess x86 version . In my local GAC the odac version is x86. But in the web server where it was installed previously was having AMB64 version of odac in GAC . The site was working without any problem . Now I need to move the site to AWS .The windows instance in AWS has the below configuration.
OS version : Microsoft windows server 2012 R2 Standard .
IIS 8.5
The server is clean and does not have any software installed .
When I try to create a site , I ended up seeing **could not load file or assembly one of its dependencies **. Through forums I installed various libraries from Oracle but I don't understand what are the exact steps needed . I was just doing trial and error.
Please let me know the software or steps to follow which needs do be installed such that my .net site which is connecting to its Oracle database works .
Edit 1 :
Hi ,
I performed the following steps .
As suggested by you I added Oracle.managedDataaccess dll(x86) . It worked well in my local.
Deployed the same code in the server.
I installed the oracle_12.1.0.1.0
In C:/oracle_12.1.0.1.0/odp.net/managed/x86 I ran the bat file for configuring the managed odac in the server. I was able to see the changes in the machine.config file .
5.Now when I ran the site I got the below error .
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. --->
System.TypeInitializationException: The type initializer for
'Oracle.DataAccess.Client.OracleClientFactory' threw an exception.
---> System.DllNotFoundException: Unable to load DLL 'OraOps12.dll': The specified module could not be found. (Exception from HRESULT:
0x8007007E) at
Oracle.DataAccess.Client.OpsInit.CheckVersionCompatibility(String
version) at Oracle.DataAccess.Client.OracleInit.Initialize() at
Oracle.DataAccess.Client.OracleClientFactory..cctor() --- End of
inner exception stack trace --- --- End of inner exception stack
trace --- at System.RuntimeFieldHandle.GetValue(RtFieldInfo field,
Object instance, RuntimeType fieldType, RuntimeType declaringType,
Boolean& domainInitialized) at
System.Reflection.RtFieldInfo.UnsafeGetValue(Object obj) at
System.Reflection.RtFieldInfo.GetValue(Object obj) at
System.Data.Common.DbProviderFactories.GetFactory(DataRow providerRow)
at
System.Data.Entity.Internal.LazyInternalConnection.CreateConnectionFromProviderName(String
providerInvariantName) at
System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings
appConfigConnection) at
System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String
name, AppConfig config) at
System.Data.Entity.Internal.LazyInternalConnection.Initialize() at
System.Data.Entity.Internal.LazyInternalConnection.get_Connection()
at Sample.Data.AbstractEFUnitOfWork2.SetClientId(String clientId)
at Sample.Web.Controllers.ApiControllerBase1..ctor(IUow uow,
IConnectionManager cm, IEnumerable`1 allowedAppUserbases, String
connectionName, Boolean allowSaves)
In order to fix this I added OraOps12 dll from c:/oracle_12.1.0.1.0/bin to the wwwroot/site/bin folder. Then I got the below error .
System.ArgumentException: Unable to find the requested .Net Framework
Data Provider. It may not be installed. at
System.Data.Common.DbProviderFactories.GetFactory(String
providerInvariantName) at
System.Data.Entity.Internal.LazyInternalConnection.CreateConnectionFromProviderName(String
providerInvariantName) at
System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings
appConfigConnection) at
System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String
name, AppConfig config) at
System.Data.Entity.Internal.LazyInternalConnection.Initialize() at
System.Data.Entity.Internal.LazyInternalConnection.get_Connection()
at Sample.Data.AbstractEFUnitOfWork2.SetClientId(String clientId)
at Sample.Web.Controllers.ApiControllerBase1..ctor(IUow uow,
IConnectionManager cm, IEnumerable`1 allowedAppUserbases, String
connectionName, Boolean allowSaves)
Checking to resolve this .
Appreciate your suggestions.

While deploying under release I get "LinkAssemblies failed" error

Just created a new project, Haven't touched anything yet except create some custom classes. Haven't touched the UI part, tried to deploy in release and I get this error:
The "LinkAssemblies" task failed unexpectedly.
Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA2006: Reference to metadata item 'System.Void Android.Support.V4.Widget.DrawerLayout::AddDrawerListener(Android.Support.V4.Widget.DrawerLayout/IDrawerListener)' (defined in 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null') from 'Xamarin.Forms.Platform.Android, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' could not be resolved. ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void Android.Support.V4.Widget.DrawerLayout::AddDrawerListener(Android.Support.V4.Widget.DrawerLayout/IDrawerListener)
at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
at Mono.Linker.Steps.MarkStep.ProcessQueue()
at Mono.Linker.Steps.MarkStep.Process()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.Process(LinkContext context)
at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
--- End of inner exception stack trace ---
at Java.Interop.Tools.Diagnostics.Diagnostic.Error(Int32 code, Exception innerException, String message, Object[] args)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() TakeAm.Droid C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets 1571
I really don't know what I've done wrong I've tried changing the target and compile versions to the latest versions but still nothing. My Forms Nuget is Updated also.
This is a known bug.
Bug 48014 - blank xaml app (xamarin.forms portable) release build fails
The bug was fixed in an alpha release:
Jose Gallardo 2016-12-02 19:54:01 UTC
.../...
We're going to replace the old cross-platform templates with a new set of templates where this issue is fixed.
That new version will be out in the next XVS 4.3 preview (which will be available in the Alpha channel probably next week).
To add to my answer, there's other issues that may need to be addressed with that update.
Taken from Xamarin Android no longer builds release after Xamarin Update, John Miller:
Check that you have the following installed:
XVS 4.2.0.703
Android SDK Tools 25.2.2
Android Platform-tools 24.0.3
Android
Build-tools 24.0.3
Android support repository 38
Java 1.8 (8u101) 64 bit (Remove Java 1.7 if you have it, see more info
here:
https://developer.xamarin.com/releases/android/xamarin.android_7/xamarin.android_7.0/)
Make sure you have API 23 or 24 installed to compile the Android
project against.

Starting application in monodevelop vs xsp4

I build an ASP.Net WebApi project with mono in Linux.
When I start (Debug/Release) the Application within Monodevelop. The application runs without errors.
Example : I start a (Debug/Release) session. Then I navigate to 127.0.0.1:9000/api/person/ . Then I receive the expected xml output.
However, when I execute the xsp4 server from within the "bin" directory. The application starts fine, but when I go to 127.0.0.1:9000/api/person/ .
I'm ending with the following exception:
Description: HTTP 404.The resource you are looking for (or one of its dependencies)
could have been removed, had its name changed, or is temporarily unavailable. Please
review the following URL and make sure that it is spelled correctly.
Details: Requested URL: /api/person/
Exception stack trace:
at System.Web.StaticFileHandler.ProcessRequest (System.Web.HttpContext context) [0x00000] in <filename unknown>:0
at System.Web.DefaultHttpHandler.BeginProcessRequest (System.Web.HttpContext context, System.AsyncCallback callback, System.Object state) [0x00000] in <filename unknown>:0
at System.Web.HttpApplication+ <Pipeline>c__Iterator1.MoveNext () [0x00000] in <filename unknown>:0
at System.Web.HttpApplication.Tick () [0x00000] in <filename unknown>:0
Im using :
Monodevelop 4.1.7
Mono: 3.2.7
Ubuntu 13.10
xsp4: same version as monodevelop is using.
bin: location of the compiled binaries of the project build with monodevelop.
Question:
What steps do i miss, which monodevelop automates?
How to get an advanced output(Browser or console) to identify the missing file?
Why is the file missing in the standalone xsp4 and not in monodevelop?
In addition: I didn't noticed this problem until i tried to deploy the app to appharbor.
xsp4 is supposed to be run from the web application directory, not from bin directory.
The reason is in the ASP.NET architecture: a web application consist of a main directory ( say webapp) and several standard directories.
Let's just focus on bin, which only contains compiled assemblies referenced by your web application.
Simply said, if you run xsp4 under the scope of the bin directory, it'll never be able to reference Index.aspx. On the other hand, running Index.aspx from webapp allows the server to load any required assembly from the bin directory

error ASPPARSE: Could not load type

If I run this command on my system
<Exec Command="C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler -v localhost -p $(SourceDir)\wwwroot -u -f projectCompileCode\project -c -errorstack -nologo" />
I get the following error:
error ASPParse: Could not load the type: Projectname:SomeFile.
The project is web application project
This my stack trace:
[HttpException]: Could not load type 'ProjectName.FileName'.
at System.Web.UI.TemplateParser.GetType(String typeName, Boolean ignoreCa
e, Boolean throwOnError)
at System.Web.UI.TemplateParser.ProcessInheritsAttribute(String baseTypeN
me, String codeFileBaseTypeName, String src, Assembly assembly)
at System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDicti
nary parseData)
[HttpParseException]: Could not load type ''ProjectName.FileName.
at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virt
alPath, Encoding fileEncoding)
at System.Web.UI.TemplateParser.ParseReader(StreamReader reader, VirtualP
th virtualPath)
at System.Web.UI.TemplateParser.ParseFile(String physicalPath, VirtualPat
virtualPath)
at System.Web.UI.TemplateParser.ParseInternal()
at System.Web.UI.TemplateParser.Parse()
at System.Web.Compilation.BaseTemplateBuildProvider.get_CodeCompilerType(
at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(
uildProvider buildProvider)
at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders()
at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
at System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResu
t(Boolean isPrecompiledApp)
at System.Web.Compilation.BuildManager.CompileGlobalAsax()
at System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
at System.Web.Compilation.BuildManager.PrecompileAppInternal(VirtualPath
tartingVirtualDir)
at System.Web.Compilation.BuildManager.PrecompileApp(VirtualPath starting
irtualDir)
at System.Web.Compilation.BuildManager.PrecompileApp(ClientBuildManagerCa
lback callback)
at System.Web.Compilation.BuildManagerHost.PrecompileApp(ClientBuildManag
rCallback callback)
at System.Web.Compilation.BuildManagerHost.PrecompileApp(ClientBuildManag
rCallback callback)
at System.Web.Compilation.ClientBuildManager.PrecompileApplication(Client
uildManagerCallback callback, Boolean forceCleanBuild)
at System.Web.Compilation.ClientBuildManager.PrecompileApplication(Client
uildManagerCallback callback)
at System.Web.Compilation.Precompiler.Main(String[] args)
If I build in v2.0.50727 then still it is giving the same error.
My application is built in with VS 2010, .net frame asp.net frame work 4
Any help is greatly apperciated.
Have you tried:
Checking references
Doing a clean and a build
Checking the Inherits attr in the HTML against the code behind
Creating a new App Pool in IIS for this web site?
I see a similar problem. Works locally from within VS2008, but once published and deployed to the server, I get the same error as described here.
None of the suggestions I have provided worked for me; maybe they will work for you.
I had the same error. When I opened the web site DLL in ILDASM, the Type for a control was completely missing, as if it didn't even get compiled.
As it turns out, the codebehind files got excluded from the project. This is strange considering that the builds on my machine were successful! At any rate, I carefully re-included codebehind files and it all started working.
This often happens because the project file (.csproj or .vbproj) does not contain the necessary references to the files in question. Try cleaning/rebuilding all projects and making sure that the latest project files are moved to the server as well.
Another possibility is that the file was not actually included in your project at all. This allows the builds in Visual Studio to run just fine, but will break when compiling the .NET code (with aspnet_compiler for example) because all .aspx/.ascx/etc. files within the specified folder are compiled - whether they are included in your project or not.

Resources