Skip to content

Could not load file or assembly System.CodeDom #186

@swASO

Description

@swASO

Describe the bug
I Updated from 0.3.1-beta to 0.5-beta and we got a exception in all our services ( linux/windows )

System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Could not load file or assembly 'System.CodeDom, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
Could not load file or assembly 'System.CodeDom, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeModule.GetTypes()
   at System.Reflection.Assembly.GetTypes()
   at flowfact.services.attributes.ServiceRegister.<>c__DisplayClass3_0.<FindTypesByAttribute>b__1(Assembly s)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator2.ToList()
   at flowfact.services.attributes.ServiceRegister.FindTypesByAttribute(Type[] types)
System.IO.FileNotFoundException: Could not load file or assembly 'System.CodeDom, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
File name: 'System.CodeDom, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
System.IO.FileNotFoundException: Could not load file or assembly 'System.CodeDom, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.

File name: 'System.CodeDom, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'

Runtime environment (please complete the following information):

  • Instrumentation mode: manual
  • Tracer version: 0.5.0-beta
  • OS: Linux / Docker image ( microsoft/dotnet:2.1-runtime-deps-stretch-slim )
  • CLR: .Net Core 2.1

Additional context
i dont know what the exact problem is, but i think this lines below does produce the error
with 0.3.1-beta everythings works fine ( already did the downgrade ), with 0.5-beta i can reproduce the exception above

private static List<(Type Type, object[] CustomAttributes)> FindTypesByAttribute(params Type[] types)
{
    try
    {
        var allTypes = AppDomain.CurrentDomain.GetAssemblies()
            .Where(s => !s.FullName.StartsWith("Microsoft") && !s.FullName.StartsWith("System."))
            .Select(s => s.GetTypes()
                .Select(type => (Type: type, CustomAttributes: type.GetCustomAttributes(true)))
                .Where(z => z.CustomAttributes.Length > 0 && z.CustomAttributes.Any(t => types.Any(i => i == t.GetType())))
            );

        return allTypes.SelectMany(s => s).ToList();
    }
    catch (Exception ex)
    {
        Logger.Error(ex);
    }
    return null;
}

Metadata

Metadata

Assignees

Labels

area:tracerThe core tracer library (Datadog.Trace, does not include OpenTracing, native code, or integrations)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions