Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to handle returns of imported dlls with DllImport in C#?
    primarykey
    data
    text
    <p>I´m unexperienced with handling DllImport stuff, so I´d be glad if anyone of you can solve my little problem. I want to import a dll which has a method within a class. The method should return a stringarray.</p> <p>So here´s some code:</p> <p>Form1.cs (Calling Position):</p> <pre><code>... public partial class Form1 : Form { [DllImport("lang.dll")] public static extern string[] getValues(); // | //error occures here v string[] labels = getValues(); Status prgmStatus; public Form1() { ... </code></pre> <p>language.cs (Class of my .dll file):</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace lang { public class language { public language() { } public string[] getValues() { string[] content = { "User", "Password", "Login", "Create new account -&gt;", "Repeat password", "E-Mail adress", "Register", "&lt;- Back to Login" }; return content; } } } </code></pre> <p>So when I start my program it calls the method of the dll and this appears:</p> <p>(Image is found here: </p> <p><img src="https://i.stack.imgur.com/eO6Ru.png" alt=""></p> <p>How may i avoid this error and get the array properly?</p> <p>Thanks for answers and solutions, Paedow</p> <p>Update:</p> <p>It should be possible to load any other .dll file from this path, with same structure but other content. The dll contains the labels for the windows form in the english language. when someone wants to have this program in his own language he has to compile a dll with his labels and just replace the dll.</p> <p>Another Update: The dll file is not build in the same solution. The dll is an own solution, only the final .dll file will be used in my program, so there are no references.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload