views:

217

answers:

2

I'm using a legacy, unmanaged, resource only c++ dll in a new c# app. I've managed to load resources from the dll using hardcoded resource numbers.

Is there any way to do this using the resource id's in C#?

The old C++ code is still being maintained, which means the resource ids/values may change. This may make the resource numbers in the c# code incorrect/invalid.

The best I can think of is to cut/paste the resource.h file into a c# class, then do some manual search/replace to format it into a c# class. This will have to be done after each change to the resource file. Is there a better way?

A: 

I'm guessing that you're not asking how to load those resources, but how to keep the ID numbers in synch?

If that's the case, I'd suggest having 2 header files where the resource IDs are defined. Use resource.h just like you do now for things you don't mind the Wizards modifying, but introduce a second header file (eg appresource.h) that you edit manually. That way you can ensure that the IDs in that file will never change. Then the only time you have to change your C# app is when you add new resources you want to use.

John Dibling
A: 

If the resource dll isn't maintained by you, I would consider writing a script/tool to do what you said, but automated (to the extent possible).

Anton