Assemblies help (resources.resx)

I tried to add a resource and messed something up in my project. I’ve been trying solve it with no success.

These are failing
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]

[global::System.CodeDom.Compiler.GeneratedCodeAttribute(“System.Resources.Tools.StronglyTypedResourceBuilder”, “4.0.0.0”)]

[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute(“Microsoft.Performance”, “CA1811:AvoidUncalledPrivateCode”)]

In one of my classes this is failing on GetFont and FontResources


        static Font _lgFont = Resources.GetFont(Resources.FontResources.NinaB);
        static Font _smFont = Resources.GetFont(Resources.FontResources.small);

Thanks

I do not think the NETMF has these classes. Did you add a class/resource file you had from a full .NET project?

How are these failing? Is it a compiler error or a runtime error?

I think you may have added another file, Resources.resx and its designer (Resources.designer.cs from another project which is causing both issues. The first one because NETMF does not have the full .NET libraries and the second one because the Resources.resx you brough in does not contain the standard font resources that are at Resources.FontResources.NinaB/small.

I tried to add an image resource.

Can you explain what steps you took to do that?

AFAIK the attributes you mentioned in the first part of you post should not be part of a NETMF/Gadgeteer project. Also, if you mention how the calls to GetFont are failing (How are these failing? Is it a compiler error or a runtime error?) it can help troubleshoot the problem.

I created a bmp in paint and then added it to the resources folder. When the image didn’t show up in the resources enumeration, I removed it.

I then came across the wiki entry, so I opened the resources.resx and added the image from there, and then I got the errors mentioned above.

The getfont errors were that those methods are not found. I’m guessing that it’s related to the other errors in the resource file.

Hmm. I opened Resources.resx, clicked Add Resource, New Image, BMP Image…, named it “MyBitmap” and built the project with no issues. If you click the arrow next to Resources.resx you should see Resources.Designer.cs under it. If you open that you should have something similar to mine below.


    internal partial class Resources
    {
        private static System.Resources.ResourceManager manager;
        internal static System.Resources.ResourceManager ResourceManager
        {
            get
            {
                if ((Resources.manager == null))
                {
                    Resources.manager = new System.Resources.ResourceManager("GadgeteerApp1.Resources", typeof(Resources).Assembly);
                }
                return Resources.manager;
            }
        }
        internal static Microsoft.SPOT.Bitmap GetBitmap(Resources.BitmapResources id)
        {
            return ((Microsoft.SPOT.Bitmap)(Microsoft.SPOT.ResourceUtility.GetObject(ResourceManager, id)));
        }
        internal static Microsoft.SPOT.Font GetFont(Resources.FontResources id)
        {
            return ((Microsoft.SPOT.Font)(Microsoft.SPOT.ResourceUtility.GetObject(ResourceManager, id)));
        }
        [System.SerializableAttribute()]
        internal enum BitmapResources : short
        {
            MyBitmap = -4296,
        }
        [System.SerializableAttribute()]
        internal enum FontResources : short
        {
            small = 13070,
            NinaB = 18060,
        }
    }

If you have any of those other attributes on the class or properties I would remove them from your code. They should not have shown up in a NETMF or Gadgeteer project.

Thanks — When I get home I’ll compare mine code to yours!

I guess worse case, I would need to recreate my project.

I would try to delete Resources.resx and add a new one. Then add the fonts and image back into it. If that does not work, then try a new project.

I used your resource code, and it was regenerated (incorrectly) the next build.

So I deleted it and recreated and all seems fine now.

I am glad you got it working. I just wonder how you got those other attributes got added to the generated code… Oh well.