代码之家  ›  专栏  ›  技术社区  ›  David Thielen

无法加载系统。资源。扩展插件。Net框架

  •  0
  • David Thielen  · 技术社区  · 5 年前

    它在TreeView上的作用非常小。

    例外情况是:

    System.IO.FileNotFoundException
      HResult=0x80070002
      Message=Could not load file or assembly 'System.Resources.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
      Source=<Cannot evaluate the exception source>
      StackTrace:
    <Cannot evaluate the exception stack trace>
    

    protected override void OnHandleCreated(EventArgs e)
        {
        SendMessage(this.Handle, TVM_SETEXTENDEDSTYLE, (IntPtr)TVS_EX_DOUBLEBUFFER, (IntPtr)TVS_EX_DOUBLEBUFFER);
        base.OnHandleCreated(e);
        }
    

    并在设置中执行以下操作:

    private void InitializeComponent()
    {
        this.SuspendLayout();
        // 
        // LinkTreeView
        // 
        this.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawText;
        this.DrawNode += new System.Windows.Forms.DrawTreeNodeEventHandler(this.LinkTreeView_DrawNode);
        this.MouseEnter += new System.EventHandler(this.LinkTreeView_MouseEnter);
        this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.LinkTreeView_MouseMove);
        this.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.LinkTreeView_NodeMouseClick);
        this.MouseLeave += new System.EventHandler(this.LinkTreeView_MouseLeave);
        this.ResumeLayout(false);
    }
    

    它有成员变量,但它们都是标准表单类:

    private Brush disabledBrush;
    private Brush foregroundBrush;
    private Brush linkBrush;
    private Brush visitedBrush;
    private Brush backGroundBrush;
    
    private Pen activeLinkPen;
    private Pen linkPen;
    private Pen visitedLinkPen;
    
    private StringFormat format;
    
    // the delete bitmap out at the end.
    private static readonly Bitmap deleteActive;
    private static readonly Bitmap deleteDisabled;
    private static readonly Rectangle rectDeleteBitmap;
    

    知道出了什么问题吗?

    0 回复  |  直到 5 年前
        1
  •  0
  •   AngelBlaZe    4 年前

    这是由于中存在的错误造成的。net 4.8及之前的版本,请参阅 https://github.com/dotnet/runtime/issues/39078

    我是在引用为其创建的库时得到它的。net核心3.1和。net框架4.8。

    请注意,您需要参考系统。资源。针对框架和应用程序的扩展。净核心。有一个新的项目属性 <GenerateResourceUsePreserializedResources>True</GenerateResourceUsePreserializedResources> 这是为了使资源捆绑对两者都有效。

    解决方法(来自bug注释,对我有效)是向应用程序添加bindingredirect。配置

      <dependentAssembly>
        <assemblyIdentity name="System.Resources.Extensions" culture="neutral" publicKeyToken="cc7b13ffcd2ddd51" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
    
    推荐文章