I am packaging resources; and I am successfully loading them from .resource files using ResourceManager.CreateFileBasedResourceManager. I want to instead create dll files with the resources, and load those with Assembly.LoadFrom; and then load the resources with new ResourceManager(string, Assembly). When I do this, I am getting:

"assembly is built by a runtime newer than the currently loaded runtime".

The project is a class library; and it is distributed and run inside of a "host" like a "plugin". The host is running .Net 3.5. My VS project is configured to target 3.5 ... and I am actually running al.exe manually to build the DLL.

I can run a test Program in my project (also set to target 3.5) and my code will load the Assembly (and find resources). But when the same code runs in the "host", I get the error.

I have tried every version of al.exe that I can find on my machine; and I specifically downloaded the .NET 3.5 SDK; which seemed to install into C:\Program Files\Microsoft SDKs\Windows\v7.0 but I always get the error no matter which version of al.exe I run.

Can someone help me build the dll so that it will load inside of this .NET 3.5 environment? --- Again it's a resource-only DLL. These are the post-build commands:

ResGen.exe AdResources.resx AdResources.resources
al.exe /target:lib /embed:AdResources.resources /culture:en /out:AdResources.resources.dll

The .cs code I use to load the Assembly and resources is like this:

string path = Path.Combine(InstallDir, "AdResources.resources.dll");
Assembly resAssembly = Assembly.LoadFrom(path);
ResourceManager temp = new ResourceManager("AdResources", resAssembly);

... Works when run in the IDE (targeting 3.5) but fails in the end host platform.

1

There are 1 answers

1
Steven Coco On BEST ANSWER

I have solved this.

Despite Hans' comments, I solved it by USING the IDE (Community 2015 RC).

I created a new class library project. Set the target to .NET 3.5 --- and made sure the App.config said the same thing. Then I copy my .resx files (only) from my main project into this project. I removed the custom tool (that generates the strong names). And the output that the IDE builds will load just fine in my host environment!

So, very odd that I can use the IDE but not the tools, even when I use the 3.5 or 2.0 tools directly; and verify that the output manifest does say "// Metadata version: v2.0.50727"!

I created a Pre-Build script to copy my resx files from the main project; and a Post-Build script to copy this library into my target output folder. Working fine ...