不是程序集的有效资源名称

Not a valid resource name of assembly

我正在使用 Xamarin Studio 和 GTK#(.NET)。我有以下问题: 我制作了一个应用程序,我需要(动态地)下载网络图像(favicons)并将它们显示在 Gtk.Image 小部件中。当我尝试这样做时,出现以下错误:

System.ArgumentException: 'myfile.ico' is not a valid resource name of assembly 'myApp, Version=1.0.6742.24722, Culture=neutral, PublicKeyToken=null'.
at at Gdk.PixbufLoader.InitFromAssemblyResource(Assembly assembly, String resource)
at at Gdk.PixbufLoader..ctor(Assembly assembly, String resource)
at at Gdk.Pixbuf..ctor(Assembly assembly, String resource)
at at Gdk.Pixbuf.LoadFromResource(String resource)

如果我在下载后在资源文件夹中添加网站图标,它会起作用,但我需要动态地进行此操作(如果我添加一个新站点,我想在那里看到它的图标..)。 代码:

using (WebClient client = new WebClient())
{
   client.DownloadFile(new Uri("https://google.com/favicon.ico", 
              Directory.GetCurrentDirectory() + "\..\..\Res\google.ico");
}

faviconImage.Pixbuf = Gdk.Pixbuf.LoadFromResource("myApp.Res.myfile.ico");

图像在文件夹中(我可以看到它,一切正常)但如果我不将它(手动)包含在资源文件夹中,我将无法使用它....

请帮帮我:'(

Pixbuf.LoadFromResource 仅从嵌入式程序集资源加载图像数据。程序集创建后无法添加资源。

要从文件创建 Pixbuf,请使用支持图像文件路径或使用文件流的 .ator

类似于:

var filePath = Path.Combine(Directory.GetCurrentDirectory(), "myDownloadIcon.ico");
var newPixBuf = new PixBuf(filePath):
faviconImage.Pixbuf = newPixBuf;