Say I build a DLL class which contains a load of resources (bitmaps), how do I access those from the program that is using the DLL?
Is this possible?
Say I build a DLL class which contains a load of resources (bitmaps), how do I access those from the program that is using the DLL?
Is this possible?
WARNING: This site referenced above is hosting dnsunlocker malware.
EDIT: The message with the bad link was marked as spam and removed.
I guess there must have been another message before your one and someone has since deleted it?
Yes, there was but is no longer…
@ Dave McLaughlin -
Hi Dave,
Ok for the site problem …
If I could add a pdf at this post I would but there is no way so you can search for “Adding Resources to a .NET Micro Framework Project” in your favorite search engine.
You can send me a PM with a link to the PDF.
I know about normal resources and do this all the time. I was looking to add them to a DLL so that I won’t exceed the max size for my application.
Not yet. I created a sample project with resources and built as a DLL.
I included this as a reference into another project but I can’t see the DLL’s resources.
I tried to make them public but it gives loads of build errors so how do you make the DLL’s resources available to the project that has included it?
A simple way would be to add a class to your DLL and add public properties that expose the resources that you are interested in exposing.
using System;
namespace MyResources
{
public class Class1
{
public Class1()
{
}
public Byte[] MyBitmap
{
get { return Resources.GetBytes(Resources.BinaryResources._12949); }
}
public String MyString
{
get { return Resources.GetString(Resources.StringResources.String1); }
}
}
}
Now in the code you can access the publically exposed resources as follows:
using Microsoft.SPOT;
using MYResources;
namespace EmbeddedResourceDLL2Test
{
public class Program
{
private static MBNResources.Class1 _resources;
public static void Main()
{
Debug.Print(Resources.GetString(Resources.StringResources.String1));
_resources = new Class1();
foreach (var b in _resources.MyBitmap)
{
Debug.Print("0x" + b.ToString("X"));
}
Debug.Print("Resource String is " + _resources.MyString);
Debug.Print("Done");
}
}
}