[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

HELP strange error

Posted on 2006-04-27
9
Medium Priority
?
288 Views
Last Modified: 2008-03-10
I am making my first vb application.
I was trying to use a folder browser and was getting errors when using that path to open a file for writing.

I got rid of the code, and for some reason I can't run my application any more.

So now I have a form with a few buttons on it and almost no code after that.
I have one button event that definitely works.

I am getting this error

System.InvalidOperationException was unhandled
  Message="An error occurred creating the form. See Exception.InnerException for details.  The error is: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
  Source="WindowsApplication1"
  StackTrace:
       at WindowsApplication1.My.MyProject.MyForms.Create__Instance__[T](T Instance)
       at WindowsApplication1.My.MyProject.MyForms.get_Form1()
       at WindowsApplication1.My.MyApplication.OnCreateMainForm()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at WindowsApplication1.My.MyApplication.Main(String[] Args)
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
0
Comment
Question by:jackjohnson44
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 1

Assisted Solution

by:mbosch
mbosch earned 400 total points
ID: 16555483
Put the code that is failing in a TRY CATCH block.  Then put a break after the exception is caught...

Try
....code...
Catch ex As Exception
  Msgbox(ex.Message.ToString)
End Try

Put the break at the Msgbox line.  Then investigate the ex in your locals windows and find the inner exception and read that exception's message.
0
 

Author Comment

by:jackjohnson44
ID: 16555537
I don't have any code, I even got rid of everything except

Public Class Form1
end class

I am not sure what is going on with the other files .net uses, but I didn't touch any of them.
I tried opening a dialog, adding "\test.txt", writing to it.
I was getting errors, so I got rid of everything and now I can't do anything.

Is there a way to figure out what lines are causing the problems?

I tried adding imports system.io on my form in various places, but got rid of it.
0
 
LVL 3

Assisted Solution

by:Kudzullc
Kudzullc earned 800 total points
ID: 16555823
Jack,

sounds like you might have items defined in your designer.vb file that do not exist on design mode.  

Imports system.io          needs to be at the very top of your initial form.  You can not add "in various places".

Can you describe what your form does?

Lucas
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:jackjohnson44
ID: 16556067
I tried putting it on my form above the class and below, but I took it out.
Like I said before, it is a blank form class with some buttons on it.

Basically I added a bunch of code to my form, then got rid of all of it.
I was trying to get rid of the problem by deleting all that I had added.

Again, the only file I touched was the form.

If something was added to designer.vb, I did not do it.


When I run the project, I get the error
"InvalidOperationException was unhandled"
I pasted the rest above.
0
 
LVL 5

Assisted Solution

by:maralans
maralans earned 400 total points
ID: 16556769
I think Jack is right, you have something defined in your designer.vb file that does not exist on design mode.  If all you have is a form with no code, I would delete the form and then create a new one. You can even copy the buttons and paste them on the new form if you want to keep them.

Good Luck
0
 
LVL 3

Accepted Solution

by:
Kudzullc earned 800 total points
ID: 16556833
Generally, designer.vb is automatically updated when moving elements into your form.  For instance, moving things in and then deleting them afterwards can sometimes hang up in the designer.vb code, causing it to not to be removed.  Especially when removing more than one elements at a time.  Like a mass deletion.  Maralans has a good idea.  It seems as though not much is invested in this form with no code, just start in over.  

Note:  all namespace references (Imports System.IO and similar) will always reside at the very top of the form.  Even above the class declaration.

gl,
Lucas
0
 
LVL 3

Expert Comment

by:Kudzullc
ID: 16556872
Just thinking...  but do you have any properties that are required to be initalized (buttons, labels, grids), say on a form load operation.  This might be a clue?  If you double click the form background you can find your form_load event.

Can you describe what your form does?

Lucas
0
 
LVL 5

Expert Comment

by:maralans
ID: 16557035
To expand on what Kudzullc is saying you can also open up the designer.vb file and see if there is a block of code or a line referencing something that is no longer on your form.
0
 
LVL 2

Assisted Solution

by:kouroshparsa
kouroshparsa earned 400 total points
ID: 16558698
For now, since you have no code, make a completely new project. Fixing what you have is harder...
Add buttons to GUI then add your own code in the button click event.
For the future, try not to modify "Windows Form Designer Generated Code"
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question