I have a simple .NET 7 console project that references a COM dll.
The code that runs in .net7 breaks after converting to .NET 8.
COM object is created successfully. Marshal.IsComObject
returns true for its instance.
However trying to access any property throws an AccessViolationException
:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Project’s platform target is x86. STAThread is applied.
The problem persists even if EmbedInteropTypes
is true or false.
What can cause the issue?
Any help would be appreciated.
Edit:
COM dll is registered using regsvr32.
Code is like below:
var obj = new InteropClass();
Console.WriteLine(obj.SomeProperty);//throws AccessViolationException
When platform target is x64 or AnyCpu then ComException
is thrown (80040154 Class not registered)
this COM dll is from third-party software and is working as expected in .net7 and before.
Switching to .net8 causes the exception.
other COM objects work great after upgrade and I wonder if there is some setting to solve this problem.
argesoft is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1