Also, I noticed that If I call these dll methods in the windows app, from a
button click on a form it works but if I call the dll methods from the forms
load event, when the form is the one passed to the Application.Run method in
the apps main() function I get the error. The only thing I can think of is
that by the time the button click happens, the application process is "fully
constructed" but when my dll method call is made from the main() function,
something under the hood in the application process isn't constructed yet.
But I need to make this call from a console application. Any body have any
ideas how to get this to work?
Works in win forms example:
private void bnTestButton_Click(object sender, System.EventArgs e)
{
DLLCall();
}
Does not work in win forms example:
[STAThread]
static void Main(string[] args)
{
Application.Run(new frmTest());
}
private void frmTest_Load(object sender, System.EventArgs e)
{
DLLCall();
}
Does not work in console example:
[STAThread]
static void Main(string[] args)
{
DLLCall();
}
"Jeremy" <no****@please.comwrote in message
news:%2******************@TK2MSFTNGP02.phx.gbl...
>I have a small block of code that uses DllImport tags to call methods in a
dll written in C. I'm not sure how the dll works internally, but when I
call some of these methods from a windows console application I get an
error, but when I call them from a windows forms application I don't get
the error.
Also, when I'm debugging through visual studio, the console application
works, but not when I run it from the command line. Strange?