Invalid Resx file. Could not load type error why?

Viewed 16232

I'm getting designer error on code:

The Component i'm willing to define a List of properties for:

using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;

namespace TestProjectForProperty.Test
{
    public class MyTreeView : TreeView
    {
        private List<TypeDescriptorBase> _descriptorsAvailable = new List<TypeDescriptorBase>();

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public List<TypeDescriptorBase> DescriptorsAvailable
        {
            get { return _descriptorsAvailable; }
            set { _descriptorsAvailable = value; }
        }
    }
}

The Descriptor itself:

using System;

namespace TestProjectForProperty.Test
{
    [Serializable]
    public class TypeDescriptorBase
    {
        public string Name { get; set; }

        public override string ToString()
        {
            return Name;
        }
    }
}

I am getting the following error if i try to use the component for example on a form and add any items on the property sheet or in the component's constructor to the DescriptorsAvailable property

Error 1 Invalid Resx file. Could not load type System.Collections.Generic.List`1[[TestProjectForProperty.Test.TypeDescriptorBase, TestProjectForProperty, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 which is used in the .RESX file. Ensure that the necessary references have been added to your project. Line 134, position 5. ...\visual studio 2010\Projects\TestProjectForProperty\TestProjectForProperty\Form1.resx 134 5 TestProjectForProperty

In the Resx file there is data field with base64 encoded stuff inside when this error is present.

I have been searching for an answer, but the best i got is to restart everything, it didn't help me, do you guys have any suggestions? I'm using .net 4 client and visual studio 2010

6 Answers

In my case I've got the error : "error MSB3103: Invalid Resx file. The specified module could not be found" executed in a light windows container based on mcr.microsoft.com/powershell instead of mcr.microsoft.com/windows:1909 (was working fine on 1909). The error was on a ressource icon that was compressed with PNG inside. It can be checked by opening the ressource on visual studio : Project > Properties > Ressources.resx, select icons, double click on the icon, check the end of the title that is either "..,BMP]" or "...,PNG]"). Updating the icon with an uncompressed format solve the "Invalid Resx file" issue.

I stumbled across this question today whilst looking for the solution to a similar issue.

Unfortunately none of the above worked for me, however my issue turned out to be that I had different versions of the .NET Framework for different projects. For example;

Project A - .NET Framework 4.7.2 Project B - .NET Framework 4

Where Project B was referencing Project A. Solution was simply to change the .NET Framework version of Project B to 4.7.2 (in my case) and hey presto the issue was resolved.

A shame Visual Studio doesn't provide a more helpful error message in this case, but something to look out for!

Related