sskodje / ScreenRecorderLib

A .NET library for screen recording in Windows, using native Microsoft Media Foundation for realtime encoding to h264 video or PNG images.
MIT License
414 stars 94 forks source link

Publish AOT not compatible? #281

Closed Disidente closed 9 months ago

Disidente commented 9 months ago

I have tried to compile with PublishAot to true. Is ScreenRecorderLib compatible or can it be compatible with AOT?

Can there be a solution with RD.XML / WinFormsComInterop / Comwrappers?

See

https://github.com/kant2002/WinFormsComInterop

Error log

1>Generating native code 1>"C:\Users\Carlos.nuget\packages\runtime.win-x64.microsoft.dotnet.ilcompiler\8.0.1\tools\ilc" @"obj\x64\Release\net8.0\win-x64\native\TestConsoleAppDotNetCore.ilc.rsp" 1>C++/CLI is not supported: 'C:\Users\Carlos\Desktop\ScreenRecorderLib\ScreenRecorderLib\bin\x64\Release\ScreenRecorderLib.dll' 1>C++/CLI is not supported: 'C:\Users\Carlos\Desktop\ScreenRecorderLib\ScreenRecorderLib\bin\x64\Release\ScreenRecorderLib.dll' 1> at ILCompiler.CompilerTypeSystemContext.AddModule(String, String, Boolean, CompilerTypeSystemContext.ModuleData, Boolean) + 0x1a8 1> at ILCompiler.CompilerTypeSystemContext.GetModuleForSimpleName(String, Boolean) + 0xa6 1> at Internal.TypeSystem.Ecma.EcmaModule.ResolveAssemblyReference(AssemblyReferenceHandle) + 0x412 1> at Internal.TypeSystem.Ecma.EcmaModule.EcmaObjectLookupHashtable.CreateValueFromKey(EntityHandle) + 0xaf 1> at Internal.TypeSystem.LockFreeReaderHashtable2.CreateValueAndEnsureValueIsInTable(TKey) + 0x11 1> at Internal.TypeSystem.Ecma.EcmaModule.ResolveTypeReference(TypeReferenceHandle) + 0x3f6 1> at Internal.TypeSystem.Ecma.EcmaModule.EcmaObjectLookupHashtable.CreateValueFromKey(EntityHandle) + 0x364 1> at Internal.TypeSystem.LockFreeReaderHashtable2.CreateValueAndEnsureValueIsInTable(TKey) + 0x11 1> at Internal.TypeSystem.Ecma.EcmaModule.GetObject(EntityHandle, NotFoundBehavior) + 0x3e 1> at Internal.TypeSystem.Ecma.EcmaSignatureParser.ResolveHandle(EntityHandle) + 0x1c 1> at Internal.TypeSystem.Ecma.EcmaSignatureParser.ParseTypeImpl(SignatureTypeCode) + 0x95 1> at Internal.TypeSystem.Ecma.EcmaSignatureParser.ParseType(SignatureTypeCode) + 0x76 1> at Internal.TypeSystem.Ecma.EcmaSignatureParser.ParseType() + 0xff 1> at Internal.TypeSystem.Ecma.EcmaSignatureParser.ParseMethodSignatureImpl(Boolean) + 0x1d9 1> at Internal.TypeSystem.Ecma.EcmaSignatureParser.ParseMethodSignature() + 0xf5 1> at Internal.TypeSystem.Ecma.EcmaMethod.InitializeSignature() + 0x19b 1> at ILLink.Shared.TrimAnalysis.FlowAnnotations.TypeAnnotationsHashtable.CreateValueFromKey(TypeDesc) + 0x7e0 1> at Internal.TypeSystem.LockFreeReaderHashtable2.CreateValueAndEnsureValueIsInTable(TKey) + 0x11 1> at ILCompiler.UsageBasedMetadataManager.HasConditionalDependenciesDueToEETypePresence(TypeDesc) + 0x99 1> at ILCompiler.DependencyAnalysis.EETypeNode..ctor(NodeFactory, TypeDesc) + 0xff 1> at ILCompiler.DependencyAnalysis.NodeFactory.CreateConstructedTypeNode(TypeDesc) + 0x75 1> at Internal.TypeSystem.LockFreeReaderHashtable2.CreateValueAndEnsureValueIsInTable(TKey) + 0x11 1> at ILCompiler.DependencyAnalysis.ReflectionInvokeMapNode.AddDependenciesDueToReflectability(DependencyNodeCore1.DependencyList&, NodeFactory, MethodDesc) + 0xd5 1> at ILCompiler.MetadataManager.GetDependenciesDueToReflectability(DependencyNodeCore1.DependencyList&, NodeFactory, MethodDesc) + 0x63 1> at ILCompiler.DependencyAnalysis.ReflectedMethodNode.GetStaticDependencies(NodeFactory) + 0x74 1> at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer2.GetStaticDependenciesImpl(DependencyNodeCore1) + 0x44 1> at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer2.GetStaticDependencies(DependencyNodeCore1) + 0x2b 1> at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer2.ProcessMarkStack() + 0xb5 1> at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer2.ComputeMarkedNodes() + 0x50 1> at ILCompiler.ILScanner.ILCompiler.IILScanner.Scan() + 0x14 1> at ILCompiler.Program.gRunScanner|4_0(Program.<>c__DisplayClass4_0&) + 0x191 1> at ILCompiler.Program.Run() + 0x2444 1> at ILCompiler.ILCompilerRootCommand.<>cDisplayClass221_0.<.ctor>b__0(ParseResult result) + 0x315 1>El comando ""C:\Users\Carlos.nuget\packages\runtime.win-x64.microsoft.dotnet.ilcompiler\8.0.1\tools\ilc" @"obj\x64\Release\net8.0\win-x64\native\TestConsoleAppDotNetCore.ilc.rsp"" salió con el código 1. ========== Compilación: 0 correcto, 0 erróneo, 3 actualizado, 0 omitido ========== ========== Compilar completado a las 6:51 y tardó 04,510 segundos ========== ========== Publicación: 0 correctos, 1 con error, 0 omitidos ========== ========== Publicar completado a las 6:51 y tardó 04,510 segundos ==========

sskodje commented 9 months ago

As the error says, and according to the documentation, C++/CLI cannot be used, and this library is written using C++/CLI. Even if you could bypass the COM issue, as far as i know, it unfortunately still won't support the language.

Disidente commented 9 months ago

Como dice el error, y según la documentación , no se puede usar C++/CLI y esta biblioteca está escrita usando C++/CLI. Incluso si pudieras evitar el problema de COM, hasta donde yo sé, lamentablemente todavía no será compatible con el idioma.

Thank you! It is understood!

ScreenRecorderLib is a great library.

I think, you could make a side project, isolating the screen capture part, to be able to use Microsoft Media Foundation in isolation, for example, to create a custom video creator.

For example.

myCustomWriter.addBmp(myBMP);