21 Mar 2023 02:03 PM - last edited on 22 Mar 2023 07:35 AM by MaciejNeumann
Environment details: docker image running under OpenShift 3.11
AgentStatus=Failed (Initializing), AD=pwsh[1]
Failed to initialize agent: Cannot marshal 'parameter #1': Cannot marshal managed types when the runtime marshalling system is disabled.
at Dynatrace.OneAgent.Sto.Detail.NativeSemanticTracingApi.NativeMethods.semanticTracing_isChannelEnabled(String name)
at Dynatrace.OneAgent.Sto.Detail.NativeSemanticTracingApi.IsChannelEnabled(String name)
at Dynatrace.OneAgent.Sto.Trace.IsChannelEnabled(String channelName)
at Dynatrace.OneAgent.Sto.Trace.GetChannel(String channelName)
at Dynatrace.OneAgent.Sto.SemanticTracer.GetTracer(String channelName, String loggingPrefix, String className, String methodName)
at Dynatrace.OneAgent.Sto.SemanticTracer.GetTracer(String channelName, String className, String methodName)
at Dynatrace.OneAgent.Agent.InitializeAgent()
Unhandled exception. System.Threading.Tasks.TaskSchedulerException: An exception was thrown by a TaskScheduler.
---> System.TypeInitializationException: The type initializer for 'Dynatrace.OneAgent.Sampling.ThreadRegistryEx' threw an exception.
---> System.Runtime.InteropServices.MarshalDirectiveException: Cannot marshal 'parameter #1': Cannot marshal managed types when the runtime marshalling system is disabled.
at Dynatrace.OneAgent.AgentNative.runtimeConfigGetBool(String configName, Boolean defaultValue)
at Dynatrace.OneAgent.Sampling.ThreadRegistryEx..cctor()
--- End of inner exception stack trace ---
at Dynatrace.OneAgent.Sampling.ThreadRegistryEx.NotifyThreadControlMethodEnter(Object threadObject, Int32 ctrlType)
at System.Threading.Thread.Start(Boolean captureContext, Boolean internalThread)
at System.Threading.Thread.UnsafeStart()
at System.Threading.PortableThreadPool.WorkerThread.TryCreateWorkerThread()
at System.Threading.PortableThreadPool.WorkerThread.MaybeAddWorkingWorker(PortableThreadPool threadPoolInstance)
at System.Threading.PortableThreadPool.RequestWorker()
at System.Threading.ThreadPool.RequestWorkerThread()
at System.Threading.ThreadPoolWorkQueue.Enqueue(Object callback, Boolean forceGlobal)
at System.Threading.ThreadPool.UnsafeQueueUserWorkItemInternal(Object callBack, Boolean preferLocal)
at System.Threading.Tasks.ThreadPoolTaskScheduler.QueueTask(Task task)
at System.Threading.Tasks.TaskScheduler.InternalQueueTask(Task task)
at System.Threading.Tasks.Task.ScheduleAndStart(Boolean needsProtection)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ScheduleAndStart(Boolean needsProtection)
at System.Threading.Tasks.Task.InternalStartNew(Task creatingTask, Delegate action, Object state, CancellationToken cancellationToken, TaskScheduler scheduler, TaskCreationOptions options, InternalTaskOptions internalOptions)
at System.Threading.Tasks.Task.Run(Action action)
at System.Management.Automation.Runspaces.EarlyStartup.Init()
at Microsoft.PowerShell.UnmanagedPSEntry.Start(String[] args, Int32 argc)
at Microsoft.PowerShell.ManagedPSEntry.Main(String[] args)
Solved! Go to Solution.
28 Mar 2023 12:26 PM
The root cause was that Dynatrace currently only supports .Net 6 which maps to PowerShell 7.2.10. The error was due to PowerShell 7.3.2 that maps to .Net 7. After downgrading to PowerShell 7.2.10, the error no longer appears.