Main Site Documentation

Does TinyCLR Implement ResourceUtility Class


#1

Hey Guys,

I was trying to port over some code from .NETMF to TinyCLR OS and was not sure what to substitute Microsoft.SPOT.ResourceUtility.GetObject() with. Below is an example of Microsoft.SPOT.ResourceUtility.GetObject() being used in my project.

internal static byte[] GetBytes(Resources.BinaryResources id)
{
return ((byte[])(Microsoft.SPOT.ResourceUtility.GetObject(ResourceManager, id)));
}


#2

I would recommend recreating your resources file instead and let the tool generate the codebehind for you. TinyCLR resources were changed from NETMF’s to more closely align with the desktop.


#3

I have recreated the resource files, but when tool generates the code it is missing some methods such as GetBytes()


#4

Is the file properly being added to the binary resources? GetBytes appears for me as expected when adding a .bin file.


#5

Thanks John, I was able to get it to work


#6

I have encountered another problem related to this topic and was wondering if anyone had a solution for it. I am trying to make new XmlReader instance using a memory stream that contains data from a binary resource file, but it keeps throwing an argumentNullexception followed by a CS7069 error. I was wondering how I can go about fixing this since System.IO.TestReader is not part of mscorlib in TinyCLR OS. Below is the line of code and the error.

XmlReader xmlReader = XmlReader.Create(newMemoryStream(data), xmlReaderSettings);

CS7069 C# Reference to type ‘TextReader’ claims it is defined in ‘mscorlib’, but it could not be found


#7

It’s probably because you added a reference to an XML library not meant for TinyCLR. That library is built against a different mscorlib, hence the error about TextReader.


#8

Yea you are right, that is the case. So is there currently no alternative for System.XML


#9

At this time, not out of the box, no.


#10

Do you have any suggestions on how I would currently be able to implement it, and also when do you guys plan on having XML supported in TinyCLR OS


#11

The .NET Core Framework source may be a good place to start for an XML implementation. The problem with NETMF’s is that it was integrated into the core so there’s not much managed code to use. We don’t have a timeline on when, or if, System.Xml will return.


#12

Thanks, I was wondering if BinaryReader has been implemented into TinyCLR, as I might be able to use that instead.


#13

BinaryReader isn’t in the current release. We will be looking into it though. In the mean time, GHIElectronics.TinyCLR.Storage.Streams.DataReader may be useful to you.