Search code examples
c#clrassemblyversions

Cannot embed C++/CLR Assembly Version number


I'm using a C++ CLR DLL in my C# WinForms app (.NET 3.5). I have set the assembly info according to all instructions found but when looking at my C# app in VS2015 the DLL metadata keeps displaying "0.0.0.0".

Here are some screenshots of my CPP and result:

Resource file - app.rc. It also includes "version.h" shown below.

App.rc

version.h:

enter image description here

When I see the DLL file properties I can see the following:

enter image description here

But at the end, when I look at my C# code generated from the managed CPP, I can see that it is "0.0.0.0":

enter image description here

Is there something I'm missing here? Thanks.


Solution

  • I found myself facing the same (or a similar) issue: I had a CLI C++ library included in a solution and its assembly version was 0.0.0.0.

    The only way I've been able to change it was to add a new source file called AssemblyInfo.cpp to che CLI C++ library containing the following lines:

    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)];
    

    After recompiling the DLL I finally read 1.0.0.0 as DLL assembly version. Hope it helps someone else!