new Newby

hi all

const char* Path = (const char*)(System::Runtime::InteropServices::Marshal:Tongue TiedtringToHGlobalAnsi(Row["Path"]->ToString() + Row["Name"]->ToString() + ".What")).ToPointer();

DBug ( "0:" + gcnew System:Tongue Tiedtring(Path) );

DWORD dwHandle;

DWORD cchver = GetFileVersionInfoSize( Path, &dwHandle);

if (cchver == 0)


HRESULT hr = HRESULT_FROM_WIN32(GetLastError());

char szMsg[1024];


DBug ( "1:" + gcnew System:Tongue Tiedtring(szMsg) + System::Environment::NewLine + "code :" + cchver.ToString());


1:The specified resource type cannot be found in the image file.

0 is the corect path

why can it not find the resorce type

this is what i wana read out : [assembly:AssemblyVersionAttribute("1.0.2")];

and i can read it whit diferent external tools so the info is definetly in the file

Re: Visual C++ Language GetFileVersionInfoSize



Your question is not clear, can you tell us exactly what the problem/question is

I was in touch with Microsoft a few months ago about a related issue on Vista x64.

You dont need any of these unmanged calls to get an assemblies version info incidentally, so I am confused by the post.


Re: Visual C++ Language GetFileVersionInfoSize

Holger Grund

GetFileVersionInfoSize and the VerXX APIs query the VERSIONINFO resource in a PE. This is something different than the managed assembly version. I think C# lets you specify some basic Win32 VERSIONINFO things which will create the resource for you.

You can check in Windows Explorer -> Properties of your file if it shows a version tab. If not, there's no VERSIONINFO resource in their.

To read the managed assembly information you'll probably use .NET Reflection APIs (just do a reflection only load of the assembly by file name and you should by able to access its metadata including version information). Of course, you could also use the unmanaged assembly metadata import interfaces, but these operate on a lower level.

OTOH, you may want your DLL to have a native version information resource. You can at least create a .res file with rc.exe and add that into your image. I believe, however, that there is some switch or tool which will add a native VERSIONINFO resource based on the managed assembly version metadata. But that would really be a question for a CLR forum or one about the toolchain you use to construct your DLL.


Re: Visual C++ Language GetFileVersionInfoSize

new Newby


i was trieing it whit :

System::Reflection::AssemblyVersionAttribute^ Attr = (System::Reflection::AssemblyVersionAttribute^) System::Attribute::GetCustomAttribute( SampleAssembly, System::Reflection::AssemblyVersionAttribute::typeid );

if (Attr == nullptr){

R = "NULL";




R = Attr->Version;


but i always geting "NULL" back

so i was tought mayby i need to get this in a diferent way

the above works fine whit the rest

AssemblyTitleAttribute, AssemblyConfigurationAttribute ...

where coud by the problem

i woud like to stay by the managed version especialy as the unmanaged way what i have tried also not working and totaly confusing is

Re: Visual C++ Language GetFileVersionInfoSize

Holger Grund

I'm not certain, but I think AssemblyVersion is not real custom attribute. Rather, it has builtin support in the metadata format and you should therefore use some member of System::Assembly.

Effectively, when the PE producer sees custom attributes it handles some of these in a special way. I think it's mentioned somewhere in the unmanaged Metadata APIs documentation.


Re: Visual C++ Language GetFileVersionInfoSize

new Newby

i have checked every thing what came in to my mind

can¡¯t find any function how i coud read it out Sad

some one

by the way thx you 2 for the sugestions

Re: Visual C++ Language GetFileVersionInfoSize

Holger Grund

C'mon it really isn't that hard:

Code Snippet

# include <msclr/auto_handle.h>

using namespace System;
using Reflection::Assembly;
using msclr::auto_handle;

int main( array<String^>^ args )
for each ( String^ s in args )
auto_handle<Assembly> as ( Assembly::ReflectionOnlyLoadFrom( s ) );
Console::WriteLine( Reflection::AssemblyName(as->FullName).Version );

FullName gives you the full name of the assembly. This includes among other things the version. The AssemblyName class can be used to parse the information. Lastly you can access the members of the Version property (type Reflection::Version) to get the individual components.

Re: Visual C++ Language GetFileVersionInfoSize

new Newby

perfect thank you

i woud have never find it

totaly confusing why you need to use a diferent path to reach it