I try to include a .csv file in my xamarin.forms project. The problem is, that I think it's only available for all the platforms at once when I use the file as an embedded resource. My assembly only has three methods:
Equals()
Load()
ReferenceEquals()
But I need Assembly.GetExecutingAssembly()
to get my code to work.
Do you know how to solve this? Or maybe an alternative? Btw: I work with Visual Studio 2013 Ultimate and the trial License of Xamarin.Android/iOS
Edit: I guess it has to do sth. with Xamarin.Forms. A normal Desktop Application hast the Assembly.GetExecutingAssembly(); and it works fine, but I need it in my App :(
Edit 2: I try out this now: http://developer.xamarin.com/guides/cross-platform/xamarin-forms/working-with/files/#Loading_Files_Embedded_as_Resources
In C#, GetExecutingAssembly() method is the method of Assembly class. This method returns the assembly that contains the code that is currently executing. To use this method we have to use System. Reflection in our program.
Namespace: System.Reflection. Summary. Defines an Assembly, which is a reusable, versionable, and self-describing building block of a common language runtime application. C# Syntax: [Serializable]
The recommended way to retrieve an Assembly object that represents the current assembly is to use the Type. Assembly property of a type found in the assembly, as the following example illustrates. To get the assembly that contains the method that called the currently executing code, use GetCallingAssembly.
Loads an assembly given its AssemblyName. The assembly is loaded into the domain of the caller using the supplied evidence. Loads the assembly with a common object file format (COFF)-based image containing an emitted assembly. The assembly is loaded into the application domain of the caller.
Do it this way:
var assembly = typeof(App).GetTypeInfo().Assembly;
Being 'App' the type of your application file.
I've done exactly what you want (reading a csv file) this way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With