I´m importing a C# DLL to a C++ Project via #import xxxx.tlb RRS feed

  • Question

  • I´m importing a C# DLL to a  C++ Project via #import xxxx.tlb 

    I have na issue Reading de config file, but just on 


    foreach (string s in Properties.Settings.Default.tpUnidade)


    as tpUnidade is a stringcolection

    I Get na EEFileLoadException, but if i continue everithing is read correctly. The second time i use this funcion no error is achieved.

    I can't figure what's the problema



    Best Regards, Vitor Sarabando

    Friday, January 19, 2018 6:16 PM

All replies

  • The .NET configuration subsystem (on which Properties.Settings relies) expects to find an <app>.exe.config file. It is this file that the subsystem will attempt to read. The subsystem will only initialize once so any errors while loading the config will only occur once.

    In general your DLL shouldn't rely on a config file being present as DLLs don't have config files and the calling app may not either (as in your case). You should either require configuration (for values that cannot be known at compile time) or default values and then accept overloads (for values that can have a reasonable default).

    In your particular case, simply adding the appropriate <app>.exe.config file will likely be sufficient to get around the issue but you should really modify your DLL logic not to require a config file at all.

    Michael Taylor

    Friday, January 19, 2018 7:34 PM