Link to home
Start Free TrialLog in
Avatar of apuma
apumaFlag for United States of America

asked on

getting an error when switching between programs and when running exe

hello experts whenever i switch to another program window then return to the project i get this error
or if i try to execute the .exe file  

An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll

Additional information: Object reference not set to an instance of an object.

the debugger then points to the first line

Public Class Form1

of my project.

i doublechecked that form1 is set as the default form    

any ideas on what could cause this?  
thanks in advance
Avatar of apuma
apuma
Flag of United States of America image

ASKER

I did some more research and it looks like i am getting this error due to a SQL connection.
i started a blank project and connected to the same database    and i get simmilar errors.

Is there a special step i need to go through to connect to a sql DB on a server   besides using the server explorer and generating a dataset?
Avatar of DotNetLover_Baan
DotNetLover_Baan

Are you doing anything in LostFocus or Deactivated events of your form?

-Baan
Avatar of apuma

ASKER

no   I can just have a blank form with only the connection set-up and i will get this error.

sounds interesting. Lets see where and how you are making the connection.
-Baan
Avatar of apuma

ASKER

i am connecting using the server explorer, which creates a sqlconnection and a sqldataadapter object in the "bin" under the design form.


if i run the project from VS it runs fine   selects and saves data with no issue.   just when i switch to another screen   then switch back.


Personally I like to make connections to the database from my code. (wizards scare me.......:() ) That in turn gives you more control on things specially when things go wrong. Moreover its easy to debug. If you want to switch to coding method, I would love to help you whenever you need it.

In your case, hmm...., how about reinstalling framework? (again I am not sure).

-Baan
Avatar of apuma

ASKER

I agree with your point about the wizards.   not the biggest fan either.   im fairly new at vb.net so i would probbably need some help figuring out how to databind in code.  im guessing it's fairly easy to just copy what the windows generated stuff does.  ill give that a shot and see what i come up with
Avatar of apuma

ASKER

So i did some more testing and i tried starting a new project in "my vasual studios projects" folder with nothing on it at all    no connections  no anything,  and i get that problem.   so it is not the sql connection causing it.     if  i run a project from my flash drive it runs perfectly. any ideas?  could this be a .net framework issue?
Quite possible. Try installing Framework SDK.
http://msdn.microsoft.com/netframework/downloads/framework1_1/

-Baan
One more thing .. how much free disk space and RAM do you have?

-Baan
Avatar of apuma

ASKER

46 gigs of free space and 512mb ram

i moved the project on to my flash drive and it runs fine from there on the same machine,   also works fine on other machines from the .exe
Avatar of apuma

ASKER

if i copy the .exe from the flash drive to the c drive that also executes without issue.  
It means that your framework is working just fine. Only when you run something in DEBUG mode with VB.Net it's not working. Chances are your VS.Net is not installed properly. What do you think?

-Baan
Avatar of apuma

ASKER

why would it work if the project was sitting on a flash drive   and not when it is on the c drive?

the only thing i can think is that maybe there is a conflict with the NTFS where as i beleive the flash storage is FAT
But when you run the exe from your hard disk it's working fine.. right?
Avatar of apuma

ASKER

yes,  i think the problem uccors during compilation, when on my c drive.
ASKER CERTIFIED SOLUTION
Avatar of DotNetLover_Baan
DotNetLover_Baan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of apuma

ASKER

re-installing from our disk is not an option as the disk is scratched.
so i may just be SOL
that or the flash drive becomes a permanent fixture to the machine