我正在为一个名为 BIM Vision 的软件创建插件。他们有一个围绕 C API 的包装器,因此我使用 UnmanagedExports 让我的非托管 DLL 用包装器编译得很好。
问题是我根本无法在我的项目中使用 NuGet 库。它们编译得很好,但是在我的代码中调用它们的任何函数都会使软件崩溃。
所有的库都与我自己的 DLL 一起编译在它们自己单独的 DLL 中。软件只能加载我的 DLL(因为其他 DLL 缺少与 BIMVision 对话的代码)
如何让软件找到丢失的 DLL?我应该把它们放在哪里?
我的 .csproj 看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{362E40F4-4A37-48B3-A7A5-93E5535A9B22}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ExcelLink</RootNamespace>
<AssemblyName>ExcelLink</AssemblyName>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>C:\Users\Daniel\Documents\SAMT\BIMVISION SDK\bim_vision_exe\plugins</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\..\bim_vision_exe\plugins\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Security" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="C:\Users\Daniel\Documents\SAMT\BIMVISION SDK\sdk .NET\BIMVision.cs">
<Link>BIMVision.cs</Link>
</Compile>
<Compile Include="ExcelLink.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="EPPlus" Version="4.5.3.3" />
<PackageReference Include="UnmanagedExports" Version="1.2.7" />
<PackageReference Include="ZetaIpc" Version="1.0.0.9" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="C:\Users\Daniel\Documents\SAMT\BIMVISION SDK\exmaples .NET\vs_2013\packages\UnmanagedExports.1.2.7\tools/RGiesecke.DllExport.targets" Condition="Exists('C:\Users\Daniel\Documents\SAMT\BIMVISION SDK\exmaples .NET\vs_2013\packages\UnmanagedExports.1.2.7\tools/RGiesecke.DllExport.targets')" />
</Project>
设法使用调试器从软件中获取真正的异常:
Exception thrown at 0x75AA9962 in bim_vision.exe: Microsoft C++ exception: EEFileLoadException at memory location 0x0019C458.