MMI icon indicating copy to clipboard operation
MMI copied to clipboard

Version 3.0.0 doesn't work with .NET 8 runtime win-x64

Open mk185147 opened this issue 2 years ago • 6 comments

Prerequisites

  • [X] Write a descriptive title.
  • [X] Make sure you are able to repro it on the latest version
  • [X] Search the existing issues.

Steps to reproduce

I build my app with .NET 8, runtime win-x64 and Microsoft.Management.Infrastructure version 3.0.0 and let it run.

I am able to get my .NET 8 app running when built with Microsoft.Management.Infrastructure version 3.0.0-preview.3, the issue is also happening with 3.0.0-preview.4.

Expected behavior

No problem

Actual behavior

When application start I get exception:

System.TypeInitializationException: The type initializer for 'Microsoft.Management.Infrastructure.Native.ApplicationMethods' threw an exception.
  ---> System.DllNotFoundException: Unable to load DLL 'Microsoft.Management.Infrastructure.Native.Unmanaged.DLL' or one of its dependencies: The specified module could not be found. (0x8007007E)
    at MI_ApplicationWrapper_Initialize(_MI_ApplicationWrapper* , UInt16* ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  ,  )
    at Microsoft.Management.Infrastructure.Native.MI_ApplicationWrapper_Initialize_Managed(_MI_ApplicationWrapper* pmiApplicationWrapper)
    at Microsoft.Management.Infrastructure.Native.ApplicationMethods.InitializeCore(InstanceHandle& errorDetails, ApplicationHandle& applicationHandle)
    at Microsoft.Management.Infrastructure.Native.ApplicationMethods..cctor()
    --- End of inner exception stack trace ---
    at Microsoft.Management.Infrastructure.Native.ApplicationMethods.Initialize(InstanceHandle& errorDetails, ApplicationHandle& applicationHandle)
    at Microsoft.Management.Infrastructure.Internal.CimApplication.GetApplicationHandle()
    at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
 --- End of stack trace from previous location ---
    at System.Lazy`1.CreateValue()
    at Microsoft.Management.Infrastructure.Internal.CimApplication.get_Handle()
    at Microsoft.Management.Infrastructure.CimSession.Create(String computerName, CimSessionOptions sessionOptions)
    at Microsoft.Management.Infrastructure.CimSession.Create(String computerName)

Error details

No response

Environment data

The application run on cotainer without powershell

Version

3.0.0

Visuals

No response

mk185147 avatar Nov 14 '23 20:11 mk185147

In addition, where is the source of version 3? It's not in this repo (or I couldn't find the right branch).

Kryptos-FR avatar Nov 18 '23 12:11 Kryptos-FR

The same issue is still present in the version v3.0.0

ds185357 avatar Jan 25 '24 12:01 ds185357

Looking into the nuget package Microsoft.Management.Infrastructure.Runtime.Win I see that the version 3.0.0 doesn't contain files runtimes*\native\mi.dll and runtimes*\native\miutils.dll which were present in the preview 3 nuget package.

mk185147 avatar Feb 06 '24 16:02 mk185147

@adityapatwardhan and @daxian-dbw can you, please, help? I saw in the ticket https://github.com/dotnet/runtime/issues/86713 that you were probably preparing a solution for use these powershell nuget packages with .NET 8 but it isn't clear to me what is the expectation. I see that mi.dll and miutils.dll aren't included in Microsoft.Management.Infrastructure.Runtime.Win anymore - is it expected? Is there other way how can I deliver these dlls to a windows container? Thanks

mk185147 avatar May 06 '24 14:05 mk185147

@mk185147 Regarding that .NET issue, the v3.0.0 of the MMI package resolves the problem -- PowerShell 7.4 and applications that host PowerShell 7.4 will continue to work without needing to make the runtimeconfig change.

I believe mi.dll and miutils.dll were removed from the v3.0.0 package because they are available under C:\Windows\System32 on Windows machines, so there is no need to include an older version of those 2 libraries in the NuGet package. But I don't know about the specifics. @adityapatwardhan made the changes and would have more insights.

daxian-dbw avatar May 07 '24 21:05 daxian-dbw

Thank you @daxian-dbw . Unfortunately, mi.dll and miutils.dll aren't present on Windows Nano Server containers, that is where is see the System.TypeInitializationException when using Microsoft.Management.Infrastructure version 3.0.0 (and it worked with 3.0.0-preview.3 where the mi.dll and miutils.dll were present). Do you know about a good way how to deliver mi.dll and miutils.dll into Windows nano cotnainers? Thanks

mk185147 avatar May 09 '24 10:05 mk185147