我正在为一个名为BIM的软件创建插件。它们围绕一个have有一个包装器,因此我使用UnmanagedExports将我的非托管DLL与包装器一起编译。
问题是我不能在我的项目中使用NuGet librairies。它们编译得很好,但在我的代码中调用它们的任何函数都会使软件崩溃。
所有库都在它们自己的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.
发布于 2020-08-25 08:00:16
使用GACUTIL安装GAC中的库DLL,如下所示,修复了这个问题。
gacutil /i [path.dll]
由于System.Buffers
包的版本不匹配,它仍然没有运行;我安装了正确的版本,并且运行正常。
https://stackoverflow.com/questions/63464993
复制相似问题