473,395 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

UnhandledExceptions and System.IO.FileNotFoundException

Hi there,

I'm wondering is there any way i can gracefully handly the
System.IO.FileNotFound exception.

Let me explain my situation.

I've got a window forms app.

I've exception handlers for
AppDomain.CurrentDomain.UnhandledException
and for
Application.ThreadException
and and a try catch around my Main/Submain

Ok this is the right way to go for handling all expcetions on windows froms
from what i read.

However displaying my exception i call something like
MyTrace.Trace(excepction);

ok so still everything fine no problems..
Unless the missing assebmly that i'm trying to load is the MyTrace assembly.

Obviously i cannot use MyTrace assembly to trace that it's not there!
So what can I do?

I though ok, i can live with letting FileNotFoundExceptions being handled
with a MessageBox.Show, so where i handle the exceptions i do something like
if (excpetion is FileNotFoundException)
MessageBox(..);
else
MyBase.Trace(exception)

However I'm still getting problems. I don't know if it's the just in time
compiler or what but if MyTrace assembly is missing then i don't get the
message box!!?
It's like the Application sees that .. hey i may use MyTrace assembly better
load it.
And it seens to happen outside my try/catch/unhandled excptions

Anyone seen this before or know how to fix it?
Nov 17 '05 #1
4 2493
Hi,

Why don;t you check for the file existence:

File.Exist( path )

You could ask for the user to enter another file

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Brian Keating" <Br**********@discussions.microsoft.com> wrote in message
news:A3**********************************@microsof t.com...
Hi there,

I'm wondering is there any way i can gracefully handly the
System.IO.FileNotFound exception.

Let me explain my situation.

I've got a window forms app.

I've exception handlers for
AppDomain.CurrentDomain.UnhandledException
and for
Application.ThreadException
and and a try catch around my Main/Submain

Ok this is the right way to go for handling all expcetions on windows
froms
from what i read.

However displaying my exception i call something like
MyTrace.Trace(excepction);

ok so still everything fine no problems..
Unless the missing assebmly that i'm trying to load is the MyTrace
assembly.

Obviously i cannot use MyTrace assembly to trace that it's not there!
So what can I do?

I though ok, i can live with letting FileNotFoundExceptions being handled
with a MessageBox.Show, so where i handle the exceptions i do something
like
if (excpetion is FileNotFoundException)
MessageBox(..);
else
MyBase.Trace(exception)

However I'm still getting problems. I don't know if it's the just in time
compiler or what but if MyTrace assembly is missing then i don't get the
message box!!?
It's like the Application sees that .. hey i may use MyTrace assembly
better
load it.
And it seens to happen outside my try/catch/unhandled excptions

Anyone seen this before or know how to fix it?

Nov 17 '05 #2
Hi Ignacio,
thanks for you help, but the file that doesn't exist is actually an assembly
that is in the gac so a simple File.Exists won't work.

Thanks for your help though

brian

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

Why don;t you check for the file existence:

File.Exist( path )

You could ask for the user to enter another file

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Brian Keating" <Br**********@discussions.microsoft.com> wrote in message
news:A3**********************************@microsof t.com...
Hi there,

I'm wondering is there any way i can gracefully handly the
System.IO.FileNotFound exception.

Let me explain my situation.

I've got a window forms app.

I've exception handlers for
AppDomain.CurrentDomain.UnhandledException
and for
Application.ThreadException
and and a try catch around my Main/Submain

Ok this is the right way to go for handling all expcetions on windows
froms
from what i read.

However displaying my exception i call something like
MyTrace.Trace(excepction);

ok so still everything fine no problems..
Unless the missing assebmly that i'm trying to load is the MyTrace
assembly.

Obviously i cannot use MyTrace assembly to trace that it's not there!
So what can I do?

I though ok, i can live with letting FileNotFoundExceptions being handled
with a MessageBox.Show, so where i handle the exceptions i do something
like
if (excpetion is FileNotFoundException)
MessageBox(..);
else
MyBase.Trace(exception)

However I'm still getting problems. I don't know if it's the just in time
compiler or what but if MyTrace assembly is missing then i don't get the
message box!!?
It's like the Application sees that .. hey i may use MyTrace assembly
better
load it.
And it seens to happen outside my try/catch/unhandled excptions

Anyone seen this before or know how to fix it?


Nov 17 '05 #3
Hi,

Ok, if the file is in the GAC then you cannot use File.Exist and I think
that the problem is that your application never is executed, as the runtime
try to load all your assemblies before running the app.

What if you load the assemblies with your code, in this way you will know if
any or which assembly failed to load.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Brian Keating" <Br**********@discussions.microsoft.com> wrote in message
news:D1**********************************@microsof t.com...
Hi Ignacio,
thanks for you help, but the file that doesn't exist is actually an
assembly
that is in the gac so a simple File.Exists won't work.

Thanks for your help though

brian

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

Why don;t you check for the file existence:

File.Exist( path )

You could ask for the user to enter another file

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Brian Keating" <Br**********@discussions.microsoft.com> wrote in message
news:A3**********************************@microsof t.com...
> Hi there,
>
> I'm wondering is there any way i can gracefully handly the
> System.IO.FileNotFound exception.
>
> Let me explain my situation.
>
> I've got a window forms app.
>
> I've exception handlers for
> AppDomain.CurrentDomain.UnhandledException
> and for
> Application.ThreadException
> and and a try catch around my Main/Submain
>
> Ok this is the right way to go for handling all expcetions on windows
> froms
> from what i read.
>
> However displaying my exception i call something like
> MyTrace.Trace(excepction);
>
> ok so still everything fine no problems..
> Unless the missing assebmly that i'm trying to load is the MyTrace
> assembly.
>
> Obviously i cannot use MyTrace assembly to trace that it's not there!
> So what can I do?
>
> I though ok, i can live with letting FileNotFoundExceptions being
> handled
> with a MessageBox.Show, so where i handle the exceptions i do something
> like
> if (excpetion is FileNotFoundException)
> MessageBox(..);
> else
> MyBase.Trace(exception)
>
> However I'm still getting problems. I don't know if it's the just in
> time
> compiler or what but if MyTrace assembly is missing then i don't get
> the
> message box!!?
> It's like the Application sees that .. hey i may use MyTrace assembly
> better
> load it.
> And it seens to happen outside my try/catch/unhandled excptions
>
> Anyone seen this before or know how to fix it?


Nov 17 '05 #4
hi again,
thanks for you help,
in the end i loaded my Diagnostic Library in the case of an unhandled
exception and this did the trick.

Thanks
Brian

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

Ok, if the file is in the GAC then you cannot use File.Exist and I think
that the problem is that your application never is executed, as the runtime
try to load all your assemblies before running the app.

What if you load the assemblies with your code, in this way you will know if
any or which assembly failed to load.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Brian Keating" <Br**********@discussions.microsoft.com> wrote in message
news:D1**********************************@microsof t.com...
Hi Ignacio,
thanks for you help, but the file that doesn't exist is actually an
assembly
that is in the gac so a simple File.Exists won't work.

Thanks for your help though

brian

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

Why don;t you check for the file existence:

File.Exist( path )

You could ask for the user to enter another file

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Brian Keating" <Br**********@discussions.microsoft.com> wrote in message
news:A3**********************************@microsof t.com...
> Hi there,
>
> I'm wondering is there any way i can gracefully handly the
> System.IO.FileNotFound exception.
>
> Let me explain my situation.
>
> I've got a window forms app.
>
> I've exception handlers for
> AppDomain.CurrentDomain.UnhandledException
> and for
> Application.ThreadException
> and and a try catch around my Main/Submain
>
> Ok this is the right way to go for handling all expcetions on windows
> froms
> from what i read.
>
> However displaying my exception i call something like
> MyTrace.Trace(excepction);
>
> ok so still everything fine no problems..
> Unless the missing assebmly that i'm trying to load is the MyTrace
> assembly.
>
> Obviously i cannot use MyTrace assembly to trace that it's not there!
> So what can I do?
>
> I though ok, i can live with letting FileNotFoundExceptions being
> handled
> with a MessageBox.Show, so where i handle the exceptions i do something
> like
> if (excpetion is FileNotFoundException)
> MessageBox(..);
> else
> MyBase.Trace(exception)
>
> However I'm still getting problems. I don't know if it's the just in
> time
> compiler or what but if MyTrace assembly is missing then i don't get
> the
> message box!!?
> It's like the Application sees that .. hey i may use MyTrace assembly
> better
> load it.
> And it seens to happen outside my try/catch/unhandled excptions
>
> Anyone seen this before or know how to fix it?


Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: ulf | last post by:
Hello, After I got a FileNotFoundException in my real life CSharp code, I nailed it down to the following line: System.EnterpriseServices.ResourcePool rp = new...
3
by: Karl Hungus | last post by:
A cs file I compiled into an assembly dll is in my bin directory. In the cs file I have a using statement for System.Xml I compiled it using this command: csc /out:XmlContent.dll /t:library...
5
by: MattC | last post by:
Hi, I am getting the following error: System.IO.FileNotFoundException: C:\Dreamtxt\WebSites\mysite\www\feedback.aspx at System.Web.UI.TemplateParser.GetParserCacheItem() at...
0
by: Eric van Wijk | last post by:
Hi All, After installing SP1 for Windows 2003, I'm running into the 'Error loading type library/DLL' exception when using CDO through System.Web.Mail: ...
3
by: James | last post by:
Hi guys Do you ever get the exception in Managed C++? How can I know which file or dll is missed?
0
by: Peter Vestergaard | last post by:
Hi, I am running VS .Net 2005. I have an application in which one of the classes are having a member that is an instance of a class defined in a managed C++ dll. As soon as I try to create an...
1
by: kkizer | last post by:
I have a problem with this simple code below. Moving the files works perfectly, but once in a blue moon the file that it is trying to move dissapears before it can move it. and when this happens...
2
by: jjlagtap | last post by:
Hey everyone When I try to open a file i get the Exception listed below. The weird thing is it works when I run the web app locally and when i use a remote server and open a file on my computer....
2
by: =?Utf-8?B?c2FtMDFt?= | last post by:
I have a remoting application that was developed on a Windows XP SP2 machine with VS2005 SP1. I finally got everything deployed using Wix 3.0, and it works great. Problem is, when I install the msi...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.