I try to load bitmap from Resource file in .Net Core app (Azure Job).
Code example
var bmp = new Bitmap(100, 100); // Works ok. Since loads it from System.Drawing.Common (from nuget 4.5 - 4.0.0.0)
var resourceBmp = TestResources.First; //Crashes runtime trying to load System.Drawing.Common 4.0.2.1
It crashes runtime with exception below:
Could not load file or assembly 'System.Drawing.Common, Version=4.0.2.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
Stack Trace:
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, StackCrawlMarkHandle stackMark,
ObjectHandleOnStack assemblyLoadContext, Boolean loadTypeFromPartialName, ObjectHandleOnStack type, ObjectHandleOnStack keepalive)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, StackCrawlMark& stackMark, AssemblyLoadContext
assemblyLoadContext, Boolean loadTypeFromPartialName)
at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, StackCrawlMark& stackMark) at
System.Type.GetType(String typeName, Boolean throwOnError) at System.Resources.ResourceReader.FindType(Int32 typeIndex)
at System.Resources.ResourceReader.DeserializeObject(Int32 typeIndex)
at System.Resources.ResourceReader._LoadObjectV2(Int32 pos, ResourceTypeCode& typeCode)
at System.Resources.ResourceReader.LoadObjectV2(Int32 pos, ResourceTypeCode& typeCode)
at System.Resources.ResourceReader.LoadObject(Int32 pos, ResourceTypeCode& typeCode)
at System.Resources.RuntimeResourceSet.GetObject(String key, Boolean ignoreCase, Boolean isString)
at System.Resources.RuntimeResourceSet.GetObject(String key, Boolean ignoreCase)
at System.Resources.ResourceManager.GetObject(String name, CultureInfo culture, Boolean wrapUnmanagedMemStream)
at System.Resources.ResourceManager.GetObject(String name)
It was working like a month ago. Something change on build machine (Azure DevOps). Locally works fine with no issues (probably locally redirection is working fine).
I tried to add also System.ResourceManager package from Nuget, but with no effect.
What I also tried - I rebuilt the old version which was still deployed on different environment. Rebuilt on new build machine and it is crashing with same exception now. Which means that it is affected somehow by building environment, not by project configuration itself. I am totally lost here
User contributions licensed under CC BY-SA 3.0