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.
So here´s some code:
Form1.cs (Calling Position):
...
public partial class Form1 : Form
{
[DllImport("lang.dll")]
public static extern string[] getValues();
// |
//error occures here v
string[] labels = getValues();
Status prgmStatus;
public Form1()
{
...
language.cs (Class of my .dll file):
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 ->",
"Repeat password",
"E-Mail adress",
"Register",
"<- Back to Login"
};
return content;
}
}
}
So when I start my program it calls the method of the dll and this appears:
(Image is found here:
How may i avoid this error and get the array properly?
Thanks for answers and solutions, Paedow
Update:
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.
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.