3F / DllExport

.NET DllExport with .NET Core support (aka 3F/DllExport aka DllExport.bat)
MIT License
937 stars 131 forks source link

How to reference other projects with DllExport #156

Closed tetradice closed 4 years ago

tetradice commented 4 years ago

Hello. Probably I think I'm overlooking the basics, but I couldn't solve it by looking at the Wiki or Issues, so please help.

I have registered two projects in one solution.

  1. Util - Class library without DLLExport.
  2. DllExportTest - Class library with DLLExport. It references the Util project.

In this state, if you build DLLExportTest and call the function, FileNotFoundException will occur before entering the process. The content of the message is that "Util, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" cannot be found.

What kind of preparation does DllExport have to do to reference the project?

DLLExportTest/Main.cs

using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace DllExportTest
{
    public class Dll
    {
        [DllExport]
        public static bool load(IntPtr dllDirPathPtr, int len)
        {
            var util = new Util.UtilClass();

            return true;
        }
    }
}

Util/UtilClass.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Util
{
    public class UtilClass
    {
    }
}

Config

WS000806

WS000807

3F commented 4 years ago

A yesterday's answer in https://github.com/3F/DllExport/issues/154#issuecomment-636503131 seems is similar to your case:

AssemblyResolve is one of the possible solutions. You can also try Pre-processing same as for Conari.

That's actually is duplicate of https://github.com/3F/DllExport/issues/86#issuecomment-429107792

Config

In future case, copy-paste from Data tab is better. Thanks.

tetradice commented 4 years ago

@3F Thanks! As with @Jesse-Schokker, using AssemblyResolve, I was able to load correctly and the problem was resolved. Thanks for your quick answer and great project.

In future case, copy-paste from Data tab is better. Thanks.

Sorry💦

3F commented 4 years ago

@tetradice Good! Thanks for using!

Sorry💦

Don't worry, just a recommendation since you have already provided minimal info for this issue. It simply covers more cases and requires less image manipulation etc.