When clicking in a specific subroutine in Visual Basic 2010, the application crashes giving only the error message "Microsoft Visual Basic 2010 [Express] has encountered a problem and needs to close."
Nothing appears in the log and safe mode doesn't help.
When I had this problem, I found it was due to a line continuation over 400 lines.
For example:
Dim someString As String
someString = "some text and then a line continuation " & _
"and then some more text for 400 lines " & _
... & _
"and then finish the string"
To fix it, I just had to make my code a little sloppier by combining multiple "lines" on one line.
Hope this helps someone else!
It sounds like you are clicking on a module or a .vb file in the solution space. Try right clicking, then "edit code" if at all possible. If there is an Interop object, perhaps a control (.OCX) that not's registered ion Windows, then VS will crash -- promise!
Related
I'm trying to get started with my first add-in for Autodesk Inventor, and of course, I'm starting from an existing sample to make this task easier for a newbie like me.
I have a decent command of VB.NET, but I cannot understand what's going on here.
In this link: https://drive.google.com/drive/folders/1rs2zVzf8Ib8iwd8JjCWZ-KQbWJUAqFyJ?usp=sharing
There are two ZIP files with VS2019 Solutions:
This_Sample_Works.zip - I used this as the baseline for my new project
This_Sample_Does_Not.zip
In both, there is this line of code:
dc.Show(New WindowWrapper(ThisApplication.MainFrameHWND))
But it only compiles in the project This_Sample_Works.zip - In the project within This_Sample_Does_Not.zip, I get the error in the image below.
Frankly, I'm not even asking someone to fix it for me. I just wanted to understand why it works in one project and not in another, despite the code being virtually the same.
What is bugging me is what piece of information/skills I currently don't have to understand what the compiler is telling me.
Public Function CreateChildDialog() As Long
CreateChildDialog = Nothing
Try
'Dim dc As Object
If Not dc Is Nothing Then
dc.Dispose()
dc = Nothing
End If
dc = New dockable_form(ThisApplication)
dc.Show(New WindowWrapper(ThisApplication.MainFrameHWND))
MsgBox("Handle ID:" & dc.Handle.ToInt64(), MsgBoxStyle.OkCancel, "Debug Info")
Return dc.Handle.ToInt64()
Catch ex As Exception
MsgBox("There is problem in CreateChildDialog" & vbCrLf & vbCrLf & ex.Message & vbCrLf & vbCrLf & ex.StackTrace & vbCrLf & vbCrLf & ex.ToString)
End Try
End Function
Any help is welcome - Thanks in advance!
In your project This_Sample_Does_Not the class dockable_form is a Control (the class inherits from System.Windows.Forms.UserControl).
In the reference project This_Sample_Works the class form_dockable is a Form (the class inherits from System.Windows.Forms.Form).
The two are very different types, though a Form can behave like a Control, the opposite is not true. A control will need a containing form.
Thus, the Control does not have a Parent that can be assigned when the method Show is called, it already has a parent.
From MSDN - Control.Show Method
Showing the control is equivalent to setting the Visible property to true. After the Show method is called, the Visible property returns a value of true until the Hide method is called.
Questions for your final preferred solution:
Do you really want to create a Control that is placed on another form? or
Do you want a Form that can be shown or popped up as required?
I have some visual basic code where i have a for loop and for company syntax reason, we need to include a _ at the en of the from in line. However, whenever I unfocus from the code, the " _ " gets deleted
I tried messing around in the option under Tools > Options > Text Editor > Basic > advance and unchecking everything but that did not help.
this is the code i want to produce:
Dim burger = (From p In db.PreviousDeclarations _
Where p.burgerID = CompanyID.Value And Object.Equals(p.Year, Year)
This is the code visual studio keep "Correcting" for me:
Dim burger = (From p In db.PreviousDeclarations
Where p.burgerID = CompanyID.Value And Object.Equals(p.Year, Year)
Uncheck Pretty listing (reformatting) of code, located in Options->Text Editor->Basic-> Advanced->Editor Help
Recent versions of Visual Studio will delete the line continuation characters when they're not necessary, typically when the first line alone would not compile on its own but the line below makes it syntactically valid. I know from experience that it's annoying when switching to a new VS that does this, as a small change can easily look like a huge refactoring when doing a diff.
I don't believe there's any way to disable the functionality. If you need them for a company style guideline I suggest you update the guidelines
I've been trying to find a way to render \r\n as actual newlines in the immediate and command window in my VB.NET 4.5.1 application. I came across this question which teaches about the nq specifier, but it appears to apply only to C#. In VB.NET, nq doesn't even appear to work because I get Expression expected printed back out at me.
Is there a different way to make newlines actually show as separate lines in the immediate or command window in VB.NET?
An easier way in visual studio 2015 is to do this in the debug window:
?string,nq
You can also do the debug version in earlier versions of VS
?System.Diagnostics.Debug.Print(string,nq)
I've discovered that the solution is to use System.Diagnostics.Debug.Print(). To reproduce the original issue, entering this into the Immediate window...
? "a" & vbCrLf & "a"
...just returns this:
"a a"
However, using this...
System.Diagnostics.Debug.Print("a" & vbCrLf & "a")
...actually shows the newline:
a
a
I just started to study Visual Basic .NET. I would like to build a dynamic system log text box.
When program is passing one point of code or function, a textbox in another form is updating with the system log.
For example, when the program starts, it appends "System start" to the textbox in another form. When the program starts to use the "cal" function, then the program appends "System: start to cal data" on the textbox in another form.
However, I am not really sure how to update this system log dynamically. Do I need to use threading? Can I do it without threading? Can anyone give me an example?
To add to Mertis's suggestion, what you can do is to fire a code which concatenates details to your textbox whenever an object is called/code is executed
for example, a function was executed:
Function sampleFunc()
.....
Textbox1.text = Textbox1.Text & vbnewline & DateTime.Now & _
" a Function was Executed"
End Function
Note that I added a datetimenow, in case you needed time details.
I have a VB.NET application that I run in debug mode.
I have 3 lines
Dim sValue$
sValue = "test"
Debug.Print sValue
When I am not running, I set a breakpoint on the lines sValue = "test", and on the line Debug.Print sValue.
Now when I start debugging, the breakpoint on the line Debug.Print sValue disappears, and the Debug.Print is not performed.
However, the breakpoint on the line sValue = "test" stays there.
Does anybody know what might go wrong here?
Switching from x86 to AnyCPU helped.
Strange.
Community,
Here is another solution for those who are using Visual Studio 2012 (Express) for Desktop. Basically, you will need to import the system diagnostics and include a specific line of code. See below:
Imports System.Diagnostics
'Write Your Code Here
Trace.Listeners.Add(New TextWriterTraceListener(Console.Out))
Debug.Print(Today) 'This will print the date in "Short" form | Carriage Return
Debug.Write(Today) 'This will print the date in "Long" form
Trace.Write(Today) 'This will print the date in "Long" form
That's it. That very first line of code is necessary so that Visual Studio will recognize the Debug & Trace classes. The 2nd line of code is needed so that the window will actually display what you need. The final three lines of code do the exact same thing, essentially.
One more thing, make sure that you are in the Output Window's "Debug" page in order to see the printout!
One last thing, if you are a rookie [like me] please make sure that you hit F5 instead of CTRL+F5 if you want Visual Studio to display "Debug.Print" in your output window.
PS. There was a way to get the output to appear in the Immediate Window; but I changed my settings and now it won't appear. So, if you'd like it there you can tinker around with the options and you'll eventually get it.