0

Is there a way I can expose My.Resources in an assembly such that I can use strongly typed resources in a project that references that assembly?

In the assembly I can access the resource file "RunTimeStrings" like so:

My.Resources.RunTimeStrings.PowerOn to return the "Power is On" string in the appropriate culture, but I want to be able to access this from an external application.

I tried just exposing the Resource file as a shared readonly property:

Return My.Resources.RunTimeStrings

but this gives the error Error 53 'RunTimeStrings' is a type and cannot be used as an expression

Matt Wilko
  • 26,994
  • 10
  • 93
  • 143

1 Answers1

1

You can't expose RunTimeStrings, it is a Module. A type, thus the error message. You'd have to expose each resource individually, that's pretty painful.

A somewhat reasonable workaround is to go back to the project's Resources tab and change the Access Modifiers combobox from Friend to Public. So you can access them in another assembly. Add a project reference if you didn't already do that.

Then syntax ought to resemble:

   Dim str = ClassLibrary1.My.Resources.RunTimeStrings.PowerOn

where ClassLibrary1 is the root namespace of the project.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536