Skip to content

C++/CLI net core doesnt work if calling via pinvoke nor via direct c++ call #114965

@jmecosta

Description

@jmecosta

Description

Hi,

Im migrating some c++cli to .net core, and we are faced with a crash when pinvoke from managed side or calling the function directly from a native side.

From manage side we could make it work by force load the c++cli dll with Assembly.Load, however in the c++ i dont have a workound... Another interesting workaround is to call a managed assembly from the c++c/li, in that case pinvoke also works.

Ive attached a sample example, where both exe native and manage fail in same way, and some comments to make the managed side work.

Example.zip

Thank you

Reproduction Steps

build and run the example

Expected behavior

no crash

Actual behavior

crash

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions