Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MissingMethodException #183

Closed
holmes000 opened this issue Jan 12, 2021 · 4 comments
Closed

MissingMethodException #183

holmes000 opened this issue Jan 12, 2021 · 4 comments

Comments

@holmes000
Copy link

Hello, I'm trying to use WPF in a C# dll with exported functions. To use WPF functions, afaik calling thread must be STA, so I have two solutions:

  1. Use CoInitializeEx in C++ before calling exported C# function.
  2. Create STA thread in C# and handle WPF related stuff there.

Either way I have to use System.Threading to create new STA thread or check current thread apartment state (to be sure no one called exported function from non-STA thread).
Here's simplified code of what I'm trying to do (using solution 1):
image

But when calling this function from C++, I'm getting MissingMethodException:
image

There are no errors/warnings on C# compilation.
What can be causing this exception?

The question is related to:

  • DllExport -version: 1.7.4.29858+c1cc52f
  • Copy-paste from Data tab:
Installed: True; 1.7.4+c1cc52f; invoked: 1.7.4
Project type: Cs
Storage: ProjectFiles
Compiler.Platform: Auto
Compiler.ordinalsBase: 1
Compiler.rSysObj: False
Compiler.ourILAsm: False
Compiler.customILAsm: 
Compiler.genExpLib: False
Compiler.peCheck: PeIl
Compiler.patches: None
PreProc.Type: ILMerge, IgnoreErr
PreProc.Cmd: 
PostProc.Type: None
PostProc.ProcEnv: $(SolutionPath);$(MSBuildThisFileFullPath)
PostProc.Cmd: 
SignAssembly: 
Identifier: F7BEC497-731F-43D8-960C-37B1189234FC
Instance: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\amd64\MSBuild.exe
Project path: C:\Users\nouser\source\repos\interops\opsinterface\opsinterface.csproj
Action: Configure
PlatformTarget: 
TargetFramework: netcoreapp3.1
TargetFrameworks: 
TargetFrameworkVersion: 
RootNamespace: 
AssemblyName: 
MgrArgs: 
MetaLib: tools\raw\lib\net20\DllExport.dll
MetaCor: tools\raw\lib\netstd\DllExport.dll
Proxy: 
StoragePath: .net.dllexport.targets
ddNS: opsinterface
ddNS max buffer: 500
UseCecil: True
intermediateFiles: False
timeout: 30000
Options: None
RootPath: C:\Users\nouser\source\repos\interops\
PkgPath: C:\Users\nouser\source\repos\interops\packages\\DllExport.1.7.4\
SlnFile: 
SlnDir: C:\Users\nouser\source\repos\interops\
DxpTarget: tools\net.r_eg.DllExport.targets
MsgGuiLevel: -1
LockIfError: 
@3F
Copy link
Owner

3F commented Jan 12, 2021

I think this is #132. But you can also check #155. Thanks!

@holmes000
Copy link
Author

holmes000 commented Jan 12, 2021

So using .NET Standard 2.0 could solve this issue?

@holmes000
Copy link
Author

Moving to .NET Standard 2.0 helped to solve this issue. Now everything works as I expected using both solutions.
However, I had to move to .NET Framework, because .NET Core supports WPF only from 3.0 (which is .NET Standard 2.1 which produces described issue).

Thanks for help and your contribution to this project!

@3F
Copy link
Owner

3F commented Jan 12, 2021

@holmes000 For 1.7.x the most stable is .NET Standard 2.0 and .NET Core 2.2. Others above are case-specific.

But this can be improved later. Follow the news.
Thanks for using,

@3F 3F added duplicate and removed question labels Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants