Thread starting problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hello,

I encounter a problem using threads. I have a simple code to use a thread :

cSurveillanceBorne = New clsThreadSurveillance
_SurveillanceThread = New Thread(AddressOf cSurveillanceBorne.SurveilleBorne)
_SurveillanceThread.Start()

This code work perfectly on my workstation. I use Visual Studio 2003, and
the CLR version is 1.1.4322.573

But when, i copy this assembly on another workstation that have only the
redistribuable CLR, the thread doesn't start !!! The only difference i have
noted is :
- CLR version is 1.1.4322.2032 on the other workstation
- Visual Studio is not installed

I'm a bit disappointed, and have tried some different way to lauch my
thread, but without success. I will be great if someone coul help...

kind regards,
 
what does your thread do? does it rely on external resources. i'm pretty
sure the thread starts, it probably dies with an exception. put another way,
i've never seen a thread not start when it wasn't due to program logic error

--
Regards,
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
_________________________
 
Hello Alvin,

Thanks for your help. The thread is a loop, it just ping an IP address at a
fixed interval. I have put a messagebox as first instruction of the thread ,
and it doesn't display. I've tried a Try..Catch block for the
_SurveillanceThread.Start(), but there is'nt error !

I will try to delete all the code of the thread, just let the messagebox,
and will post back the results.


Alvin Bruney said:
what does your thread do? does it rely on external resources. i'm pretty
sure the thread starts, it probably dies with an exception. put another way,
i've never seen a thread not start when it wasn't due to program logic error

--
Regards,
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
_________________________
 
Hello Again,

I found why the thread wasn't starting. In fact, you put me on the way
alvin. With a simple messagebox the thread was starting. What is very
confusing, is that when an error produce in a thread, the thread doesn't fire
any error, so it's very difficult to debug.

I have put the faulty code in a simple method, and what was my surprise when
an error displayed me that it can't found Microsoft.VB6 compatibility library
! My thread was using VB6.GetPath, and it work perfectly on my workstation,
but just doesn't work on the other because the version of this library is not
the same.

So i'm a bit disappointed, i thought that DLL hell was finished with the
framework DotNet, but not ! Should i have to include all the framework DLL
that i import in my project when i install it on another PC, or there is an
easier way by configuring a config file ?

Thanks,

Cedric

cedric said:
Hello Alvin,

Thanks for your help. The thread is a loop, it just ping an IP address at a
fixed interval. I have put a messagebox as first instruction of the thread ,
and it doesn't display. I've tried a Try..Catch block for the
_SurveillanceThread.Start(), but there is'nt error !

I will try to delete all the code of the thread, just let the messagebox,
and will post back the results.


Alvin Bruney said:
what does your thread do? does it rely on external resources. i'm pretty
sure the thread starts, it probably dies with an exception. put another way,
i've never seen a thread not start when it wasn't due to program logic error

--
Regards,
Alvin Bruney
[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
_________________________


cedric said:
hello,

I encounter a problem using threads. I have a simple code to use a thread
:

cSurveillanceBorne = New clsThreadSurveillance
_SurveillanceThread = New Thread(AddressOf
cSurveillanceBorne.SurveilleBorne)
_SurveillanceThread.Start()

This code work perfectly on my workstation. I use Visual Studio 2003, and
the CLR version is 1.1.4322.573

But when, i copy this assembly on another workstation that have only the
redistribuable CLR, the thread doesn't start !!! The only difference i
have
noted is :
- CLR version is 1.1.4322.2032 on the other workstation
- Visual Studio is not installed

I'm a bit disappointed, and have tried some different way to lauch my
thread, but without success. I will be great if someone coul help...

kind regards,
 
Hi Cedric,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that one of your thread is terminated with
an exception. If there is any misunderstanding, please feel free to let me
know.

As Alvin mentioned, when an exception is thrown by the sub thread, the main
thread will not be aware of it and the sub thread is terminated. We can
only get known of it in the appdomain. Try to add the following code:

static void Main()
{
AppDomain.CurrentDomain.UnhandledException +=new
UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.Run(new Form1());
}

private static void CurrentDomain_UnhandledException(object sender,
UnhandledExceptionEventArgs e)
{
MessageBox.Show("Exception thrown");
}

I see that you are using the VB6 code in you VB.NET project. It might be
the cause of the exception, because these methods doesn't exist in .NET
framework and need to interop with unmanaged DLLs. So you might need to
redistribute these DLLs with your app.

Could you let me know what you're trying to do with the VB6 code, so that I
can find an equivalent way using .NET class library to achieve that. Could
you please provide me with the thread code? Thanks!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Hello Kevin,

Thanks for your help. Sorry for the multi-posting, the first time, my
browser return me that there were a problem with my request, so i clicked
twice... You're right, my thread was terminated with an exception. Thanks for
your snippet, i will add this to my code in order to handle sub Thread errors
now.

I was using "VB6.GetPath" from Microsoft.VisualBasic.Compatibility.dll, in
order to get the path where the app is installed. I have replaced it by
"Application.StartupPath". I'm not sure it's the same (because startup path
may not be the same as the application path), but it seems to work.

The problem was, that Microsoft.VisualBasic.Compatibility.dll is present in
the CLR of my workstation, but not on the other one. So without the DLL, no
way to work :) What i don't understand is why this dll is not present in the
other framework. I use Visual Studio, and maybe it adds some dll, that the
redistribuable framework don't include...

Thanks,

Cedric
 
Hi Cedric,

Yes, you can use Application.StartupPath for an equivalence. As I
know,Microsoft.VisualBasic.Compatibility.dll is installed with Visual
Studio .NET. It is used by VB6 upgrade wizard, and is not a part of .NET
framework. So it's better to use a .NET framework method to achieve this.
HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top