我发现自己面临相同(或类似)的问题:我的解决方案中包含一个 CLI C++ 库,其程序集版本为 0.0.0.0。
我能够更改它的唯一方法是将名为AssemblyInfo.cpp的新源文件添加到包含以下行的 che CLI C++ 库中:
using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::CompilerServices;
using namespace System::Runtime::InteropServices;
using namespace System::Security::Permissions;
[assembly:AssemblyTitleAttribute(L"CliLibrary")];
[assembly:AssemblyDescriptionAttribute(L"")];
[assembly:AssemblyConfigurationAttribute(L"")];
[assembly:AssemblyCompanyAttribute(L"")];
[assembly:AssemblyProductAttribute(L"CliLibrary")];
[assembly:AssemblyCopyrightAttribute(L"Copyright (c) 2019")];
[assembly:AssemblyTrademarkAttribute(L"")];
[assembly:AssemblyCultureAttribute(L"")];
[assembly:AssemblyVersionAttribute("1.0.0.0")]; // <-- This is the version string
[assembly:ComVisible(false)];
[assembly:CLSCompliantAttribute(true)];
重新编译 DLL 后,我终于将1.0.0.0读取为 DLL 程序集版本。希望它可以帮助别人!