.NET help!

puffpio

Golden Member
Dec 21, 1999
1,664
0
0
So I made this program and it references some dll's as well as load some config files

On my computer (the development machine) it runs just fine...

I take it over to another computer and I get that error.
That computer does not have visual studio installed so I can't debug it over there, and I can't reproduce it over here!

Any suggestions/
 

Spydermag68

Platinum Member
Apr 5, 2002
2,608
96
91
Is the directory structure to the DLLs and config files the same? I had this problem once and that fixed it.
 

puffpio

Golden Member
Dec 21, 1999
1,664
0
0
the thing is..it's giving my a FileLoadException..not a FileNotFoundException

so it can find all the libs..just can't load em...
 

Tencntraze

Senior member
Aug 7, 2006
570
0
0
It sounds like your code doesn't have the correct security permissions to load the file. I'm on my way out the door so I can't verify, but I *think* the FileInfo class might have a property that lets you know if you have permissions; also you could assert for the permission in your code as a safety check before trying to load it.
 

puffpio

Golden Member
Dec 21, 1999
1,664
0
0
yeah it's strange stuff

my program loads 2 dll's from the system32 dir..i checked the permissions both on my box and the target box, and they are the same
it loads 1 dll i made myself in the same directory as the program...again the permissions are the same on both boxes

the only ones i didn't check are the .net libraries..but why would they fail to load? I dont even know where teh .net dll's are installed...
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
Originally posted by: puffpio
yeah it's strange stuff

my program loads 2 dll's from the system32 dir..i checked the permissions both on my box and the target box, and they are the same
it loads 1 dll i made myself in the same directory as the program...again the permissions are the same on both boxes

the only ones i didn't check are the .net libraries..but why would they fail to load? I dont even know where teh .net dll's are installed...

I think Tencntraze is probably on target with this one, but it might also be a versioning issue. If the DLL being loaded doesn't have an export that the program expects you'll also get this, or a similar, error.
 

Schnieds

Senior member
Jul 18, 2002
518
0
0
Are you trying to load anything other than assemblies (i.e. an image, open an XML file, etc.?) Have you referenced any 3rd party or custom libraries in your app that you have installed on your dev machine that you didn't copy to the BIN folder before you moved it to the new machine?
 

Mark R

Diamond Member
Oct 9, 1999
8,513
16
81
Do you know which line is the one that is throwing the exception? Or does the exception get thrown before you even get into your code?

If you don't already have one, then add a custom thread exception handler to your program, which can log the exception (and source code line from which it came from) to a file before the program terminates. Such an exception handler should be able to record a full stack trace including line numbers, if you use a debug binary and include the .pdb symbol file. (Of course, this won't help if execution never gets into your code).
 

puffpio

Golden Member
Dec 21, 1999
1,664
0
0
I tried it on a different machine and got a FileNotFoundException instead..
So I wrapped a try/catch block around the main function to the program

and the exception is thrown in the constructor of the Form
ie in the "Application.Run(new mainForm());" where mainForm is my initial form

the exception is thrown on mainForm..ctor() so before any of my code in the constructor even gets executed.

Interestingly, the FileName attribute was empty! So Even though it was a FileNotFoundException, there was no Filename to speak of..
VERY STUMPED
 

Schnieds

Senior member
Jul 18, 2002
518
0
0
If you wrapped the try/catch around your main function that isn't going to help. You need to wrap it around anything that access a file.

Answer these questions:

1) Did you reference any libraries (dlls) that are not included in the standard MS Framework?
2) Are you trying to load any specific files or resources in your code? If so, post it here.
3) Do you have the correct Framework version installed on the client machines?
 

puffpio

Golden Member
Dec 21, 1999
1,664
0
0
well i try/catched both teh main, and the code in the constructor for the Form. The outer main try/catch is the one that picked up the exception, not the try/catch block in the constructor of the form..which leads me to believe that this error occurs before any of my constructor code is run

I reference a DLL that I made in C#, which is in the same directory as the executable. That DLL references 2 C unmanaged DLLs not coded in .net which are located in the system32 folder.
I also reference the MS Office Interop stuff which is included in an installation of Office 2003 (which the target computers have)

it all works fine and dandy on my dev box...on other computers i get those exceptions
 

Tencntraze

Senior member
Aug 7, 2006
570
0
0
Try downloading FileMon:

FileMon

A great utility, and you can see what files are failing to be loaded for your application, if you are having trouble catching it in your code.

EDIT: Mashed buttons and ended up with a blank reply, so actually provided something of value.
 

Schnieds

Senior member
Jul 18, 2002
518
0
0
I'll bet dollars to donuts the problem is in the referenced files.

Make sure that all of the referenced files are in EXACTLY the same location as they are in your dev box, also make sure that all of the referenced DLLs exist on your client computers. While you are at it, make sure that your app will have the security permissions necessary to access the referenced libraries.
 

puffpio

Golden Member
Dec 21, 1999
1,664
0
0
Originally posted by: Tencntraze
Try downloading FileMon:

FileMon

A great utility, and you can see what files are failing to be loaded for your application, if you are having trouble catching it in your code.

EDIT: Mashed buttons and ended up with a blank reply, so actually provided something of value.

yeah I use depends.exe (w/ visual studio) to look at all that
 

puffpio

Golden Member
Dec 21, 1999
1,664
0
0
I got further info from the exception:


Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'MyForm, Version=1.0.xxxx.xxxxxx, Culture=neutral, PublicKeyToken=null' or one of its dependencies. This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix


a quick search on google reveals there is no singular cause for this type of error