小编Dan*_*iel的帖子

在Contructor中初始化后,C#静态成员变为null

我有一个包含静态ImageSource对象的类,这些对象以后经常被其他类访问:

public class ImagePrepare
{
    public static readonly ImageSource m_imageGreen;
    public static readonly ImageSource m_imageYellow;
    public static readonly ImageSource m_imageRed;
    public static readonly ImageSource m_imagePurple;

    public static int iTest;

    //static Constructor
    static ImagePrepare()
    {
        iTest = 2;

        Uri uriImage = new Uri("pack://application:,,,/" + Assembly.GetExecutingAssembly().GetName().Name + ";component/" + "Ressourcen/Button_Green.png", UriKind.Absolute);
        ImageSource m_imageGreen = new BitmapImage(uriImage);

        uriImage = new Uri("pack://application:,,,/" + Assembly.GetExecutingAssembly().GetName().Name + ";component/" + "Ressourcen/Button_Yellow.png", UriKind.Absolute);
        ImageSource m_imageYellow = new BitmapImage(uriImage);

        uriImage = new Uri("pack://application:,,,/" + Assembly.GetExecutingAssembly().GetName().Name + ";component/" + "Ressourcen/Button_Red.png", …
Run Code Online (Sandbox Code Playgroud)

c# static bitmapimage

1
推荐指数
1
解决办法
51
查看次数

标签 统计

bitmapimage ×1

c# ×1

static ×1