Mohamad Mahmoud Mohamad Mahmoud - 1 month ago 12x
C# Question

System.Reflection.Assembly does not contain a definition for 'GetExecutingAssembly'

I am trying to create Mobile App Using Xamarin.forms (Portable Project)


using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using System.Reflection;
using System.IO;
using PCLStorage;

namespace MnakbAlshaba
public class BookPage : ContentPage

private void SetBookPagesRows()
var assembly = typeof(BookPage).GetTypeInfo().Assembly.GetExecutingAssembly();//error
var resourceName = "MyCompany.MyProduct.MyFile.txt";

using (Stream stream = assembly.GetManifestResourceStream(resourceName))
using (StreamReader reader = new StreamReader(stream))
string result = reader.ReadToEnd();

I Get the following Error:

'System.Reflection.Assembly' does not contain a definition for
'GetExecutingAssembly' and no extension method 'GetExecutingAssembly'
accepting a first argument of type 'System.Reflection.Assembly' could
be found (are you missing a using directive or an assembly
reference?) C:...

var assembly = Assembly.GetAssembly(typeof(BookPage));