locked
Best practice of resource sharing (e.g. string) between C# (.Net) and C++ (unmanaged) RRS feed

  • Question

  • I've C# and C++ client which needs to retrieve the shared string resources. Is there a best practice to artchitect this so the developers don't need to create the same resource twice, one for C# (.resx/.resource) and C++ (.rc) ?

     

    Currently I can think of the following options:-

    1. Add string resource to .resx --> create a tool to convert .resx to .rc -> so both C# and C++ client have their own set of resource dll to use at run time..

    2. Add string resource to .resx --> create an interop proxy between the C++ client and .Net resource dll, so C++ client can still access updated resource via interop.

    3.Add string resource to .resx --> create a C++ helper for C++ client to read the .resx/.txt/resource dll directly.

    4. ..

     

    I'm not too sure what I think is the good solution, please advise, thanks.

    Thursday, December 20, 2007 7:08 AM

Answers

  • I meant option (3). A nice generic win32 wrapper, although you'll probably need to be careful to ensure that the thread localisation is correct in order to make use of the automatic language loading from .net.

     

     

    Wednesday, January 2, 2008 9:14 AM

All replies

  • What C++ are you talking about, win32 or .net? If it's the latter then you can create a satellite resource assembly? If it's win32 then I'd go with 4.



    Saturday, December 22, 2007 8:12 PM
  • Hi,

    I would put the messages into a single shared dll and access them via a proxy pattern.

     

    If it is just your own application accessing the string resources then I don't think there is any clear winner for whether it should be a .NET or native string resource.

     

    However if you plan on using it for the Event Log then I would use native.

    Sunday, December 23, 2007 12:55 PM
  • Hi pkr2000,

     

    Yes, it's win32 C++. So what is the option 4 you suggested?

     

    Thanks.

    Saturday, December 29, 2007 11:16 AM
  • I meant option (3). A nice generic win32 wrapper, although you'll probably need to be careful to ensure that the thread localisation is correct in order to make use of the automatic language loading from .net.

     

     

    Wednesday, January 2, 2008 9:14 AM
  • Another option would be to use the ResourceManager class directly by creating a mixed assembly.
    If your library/program file needs to stay native you would then need to create a native/cli proxy dll for the Resource Manager.
    Tuesday, March 25, 2008 9:35 PM