474,040 Members | 4,800 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

UnhandledExcept ions and System.IO.FileN otFoundExceptio n

Hi there,

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

Let me explain my situation.

I've got a window forms app.

I've exception handlers for
AppDomain.Curre ntDomain.Unhand ledException
and for
Application.Thr eadException
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(e xcepction);

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 FileNotFoundExc eptions being handled
with a MessageBox.Show , so where i handle the exceptions i do something like
if (excpetion is FileNotFoundExc eption)
MessageBox(..);
else
MyBase.Trace(ex ception)

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 2541
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**********@d iscussions.micr osoft.com> wrote in message
news:A3******** *************** ***********@mic rosoft.com...
Hi there,

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

Let me explain my situation.

I've got a window forms app.

I've exception handlers for
AppDomain.Curre ntDomain.Unhand ledException
and for
Application.Thr eadException
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(e xcepction);

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 FileNotFoundExc eptions being handled
with a MessageBox.Show , so where i handle the exceptions i do something
like
if (excpetion is FileNotFoundExc eption)
MessageBox(..);
else
MyBase.Trace(ex ception)

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**********@d iscussions.micr osoft.com> wrote in message
news:A3******** *************** ***********@mic rosoft.com...
Hi there,

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

Let me explain my situation.

I've got a window forms app.

I've exception handlers for
AppDomain.Curre ntDomain.Unhand ledException
and for
Application.Thr eadException
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(e xcepction);

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 FileNotFoundExc eptions being handled
with a MessageBox.Show , so where i handle the exceptions i do something
like
if (excpetion is FileNotFoundExc eption)
MessageBox(..);
else
MyBase.Trace(ex ception)

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**********@d iscussions.micr osoft.com> wrote in message
news:D1******** *************** ***********@mic rosoft.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**********@d iscussions.micr osoft.com> wrote in message
news:A3******** *************** ***********@mic rosoft.com...
> Hi there,
>
> I'm wondering is there any way i can gracefully handly the
> System.IO.FileN otFound exception.
>
> Let me explain my situation.
>
> I've got a window forms app.
>
> I've exception handlers for
> AppDomain.Curre ntDomain.Unhand ledException
> and for
> Application.Thr eadException
> 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(e xcepction);
>
> 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 FileNotFoundExc eptions being
> handled
> with a MessageBox.Show , so where i handle the exceptions i do something
> like
> if (excpetion is FileNotFoundExc eption)
> MessageBox(..);
> else
> MyBase.Trace(ex ception)
>
> 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**********@d iscussions.micr osoft.com> wrote in message
news:D1******** *************** ***********@mic rosoft.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**********@d iscussions.micr osoft.com> wrote in message
news:A3******** *************** ***********@mic rosoft.com...
> Hi there,
>
> I'm wondering is there any way i can gracefully handly the
> System.IO.FileN otFound exception.
>
> Let me explain my situation.
>
> I've got a window forms app.
>
> I've exception handlers for
> AppDomain.Curre ntDomain.Unhand ledException
> and for
> Application.Thr eadException
> 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(e xcepction);
>
> 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 FileNotFoundExc eptions being
> handled
> with a MessageBox.Show , so where i handle the exceptions i do something
> like
> if (excpetion is FileNotFoundExc eption)
> MessageBox(..);
> else
> MyBase.Trace(ex ception)
>
> 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
6726
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 System.EnterpriseServices.ResourcePool(null); The exception I get for this line is System.IO.FileNotFoundException: The specified module could not be found.
3
2091
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 XmlContent.cs When I run my aspx page, which has a codebehind that instantiates the object from in my assembly, I get the following error, anyone know why? File or assembly name System.Xml, or one of its dependencies, was not found.
5
2277
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 System.Web.UI.TemplateControlParser.CompileAndGetParserCacheItem(String virtualPath, String inputFile, HttpContext context) at System.Web.UI.TemplateControlParser.GetCompiledInstance(String virtualPath,
0
1851
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: ------------------------------------------- //try { // security assertion
3
9103
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
1432
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 instance of the local class I get a FileNotFoundException not telling much more than the file cannot be found. I have made the below code that reproduces this behaviour. What I don't understand is that the debugger is reporting that the...
1
7164
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 the "System.IO.Move" goes in to a loop and keeps creating the file on the destination folder with a 0byte size and keeps entering the error in the log i have until someone stop the service. so what i cant figure out is since it catches the...
2
7979
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. When someone else uses the web app and tries to open a file using the remote server the error below happens. any help? **Code** C# - filepath is a valid file name which is passed via the form. System.IO.BinaryReader br = new...
2
11043
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 on a W23 server SP2, I get the following error: System.Runtime.Remoting.RemotingException: Remoting configuration failed with the exception 'System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation....
0
10333
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11596
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11999
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
11137
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
10301
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8687
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6646
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
5403
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.