difference between a console app and a win forms app
difference between a console app and a win forms app
am 27.09.2007 20:27:04 von Kazi
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?
Re: difference between a console app and a win forms app
am 27.09.2007 20:39:57 von Kazi
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" wrote in message
news:%23%23CmBQTAIHA.4568@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?
>
Re: difference between a console app and a win forms app
am 28.09.2007 05:48:24 von unknown
"Jeremy" wrote in message
news:%23%23CmBQTAIHA.4568@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
Ok, so, which error is it? Please post the entire exception (which is what I
presume you meant by "error").
--
------------------------------------------------------------ --------------------
John Saunders | MVP - Windows Server System - Connected System Developer
Re: difference between a console app and a win forms app
am 28.09.2007 12:04:24 von Leon Lambert
I am not sure of what your particular problem is but i have seen a
similar one in the past. My problem was the DLL either was or used a COM
component. It seemed that when used with .Net console the COM layer
wasn't initialized properly or didn't have a message pump. Mine also
worked fine if i called it from Windows application. I ended up having
to make a C# COM interface assembly to wrap the C dll. The C# COM
assemble magically setup everything it took to make the C COM DLL happy.
Hope this helps.
Leon Lambert
Jeremy wrote:
> 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?
>
>
Re: difference between a console app and a win forms app
am 28.09.2007 18:42:44 von Kazi
The error is "the remote workstation has not initialized the mrwscript.dll"
It's not a .net exception as it's being generated from within the dll.
"John Saunders [MVP]" wrote in message
news:eYnqoJYAIHA.4984@TK2MSFTNGP06.phx.gbl...
> "Jeremy" wrote in message
> news:%23%23CmBQTAIHA.4568@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
>
> Ok, so, which error is it? Please post the entire exception (which is what
> I presume you meant by "error").
> --
> ------------------------------------------------------------ --------------------
> John Saunders | MVP - Windows Server System - Connected System Developer
>