gpt4 book ai didi

c# - System.Reflection.Assembly 不包含 'GetExecutingAssembly' 的定义

转载 作者:行者123 更新时间:2023-11-30 14:50:54 26 4
gpt4 key购买 nike

我正在尝试使用 Xamarin.Forms(可移植类库)创建移动应用程序,在以下代码中,我无法使用 `GetExecutingAssembly:

    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();
}
}
}
}

我收到以下错误:

'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));

关于c# - System.Reflection.Assembly 不包含 'GetExecutingAssembly' 的定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35655726/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com