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

System.MissingMethodException in C#/EExternalException in Delphi when calling a C# exported function that calls another exported function #155

Closed
meindratheal opened this issue Jun 1, 2020 · 4 comments

Comments

@meindratheal
Copy link

meindratheal commented Jun 1, 2020

Steps to reproduce:

  1. Create a new solution with two projects, a Class Library and something runnable (I've used both a console app and a forms application). I'm targeting .NET Framework 4.7.2. Can also reproduce if targeting 4.5.0.
  2. Install the NuGet package on the Class Library. When the DllExport configuration pops up, tick the Installed button on the Class Library project, then hit Apply. No other changes needed.
  3. Write two exported functions in the Class Library project. Have the second one call the first. So something like this:
        [DllExport]
        public static void WorksFine()
        {
            //Does nothing.
        }

        [DllExport]
        public static void CausesError()
        {
            WorksFine();
        }
  1. Call those functions from with C#. Observe that you get System.MissingMethodException when CausesError tries to call WorksFine.
	static void Main(string[] args)
	{
		Console.WriteLine("Calling WorksFine");
		Exports.WorksFine();
		Console.WriteLine("Calling CausesError");
		Exports.CausesError(); //Throws System.MissingMethodException: 'Method not found: 'Void TheDll.Exports.WorksFine()'.'
		Console.WriteLine("Done");
		Console.ReadKey();
	}

In my use case I'm consuming these exports in a Delphi program. Calling WorksFine works fine, calling CausesError generates an EExternalException on the Delphi side, which indicates that an uncaught exception happened in the C# side (which would be the MissingMethodException).
. . .

  • .NET DllExport 1.7.1.6918+61defd6
  • VS2019 v16.5.5, using .NET Framework 4.7.2 for the projects.
    Data tab:
Installed: True
Project type: Cs
PkgVer: 1.7.1
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: None
PreProc.Cmd: 
PostProc.Type: None
PostProc.ProcEnv: $(SolutionPath);$(MSBuildThisFileFullPath)
PostProc.Cmd: 
SignAssembly: 
Identifier: C038D930-FF6E-498C-B66E-21E3457C5B40
Instance: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\amd64\MSBuild.exe
Project path: C:\Users\redacted\source\repos\DllExportBug\TheDll\TheDll.csproj
Action: Configure
PlatformTarget: x86
TargetFramework: 
TargetFrameworks: 
TargetFrameworkVersion: v4.5
RootNamespace: TheDll
AssemblyName: TheDll
MgrArgs: 
MetaLib: tools\raw\lib\net20\DllExport.dll
MetaCor: tools\raw\lib\netstd\DllExport.dll
Proxy: 
StoragePath: .net.dllexport.targets
ddNS: TheDll
ddNS max buffer: 500
UseCecil: True
intermediateFiles: False
timeout: 30000
RootPath: C:\Users\redacted\source\repos\DllExportBug\
PkgPath: C:\Users\redacted\source\repos\DllExportBug\packages\\DllExport.1.7.1\
SlnFile: 
SlnDir: C:\Users\redacted\source\repos\DllExportBug\.\
DxpTarget: tools\net.r_eg.DllExport.targets
MsgGuiLevel: -1
LockIfError: 

Demo Project files / Samples / etc.:

Minimal sample project attached.
DllExportBug.zip

@meindratheal meindratheal changed the title EExternalException in Delphi when calling a C# exported function that calls another exported function System.MissingMethodException in C#/EExternalException in Delphi when calling a C# exported function that calls another exported function Jun 1, 2020
@meindratheal
Copy link
Author

Edited title and body to include that this also happens if everything's purely in C#, rather than calling from Delphi.

@3F
Copy link
Owner

3F commented Jun 1, 2020

@meindratheal Is there any reason why are you avoiding our bug issue template ? Please update information.

It can be a duplicate of #130

@meindratheal
Copy link
Author

That would be because I didn't know that template existed! I've updated to match, and also attached a minimal repro.

@3F
Copy link
Owner

3F commented Jun 1, 2020

Thanks for the updated information! This is duplicate of #94

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