"TryCF" in Visual Studio 2015 (VB.NET) - vb.net

I just found the very handy "TRYCF" hotkey in VS2015 - for those unaware, you can type "trycf", hit tab and it lays the following out for you:
Try
Catch ex As ArgumentException
Finally
End Try
This would be amazing, and would save me a lot of time in my day to day coding, except the default exception type "ArgumentException" is no good for me, I just want to catch generic exceptions: "ex as exception"
Does anyone know how I can set VS2015 up so that the default exception is just an "exception"?
Cheers.

You are invoking a code snippet. You could edit the snippet file and change the <Default> tag.
For VS2015, the path to those snippets is: "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VB\Snippets\1033\common code patterns\exception handling".
A recommended alternative is to copy the subject snippet to your personal snippet folder.
C:\Users\UserName\Documents\Visual Studio 2015\Code Snippets\Visual Basic\My Code Snippets
Then edit it to change the <Default> tag. Also change the <ShortCut> tag so that it does not conflict with the pre-installed VS snippet.

Related

Debug Design Mode in Visual Studio not breaking

So I am currently unable to open a Form and get the following error:
System.ComponenetModel.Design.ExceptionCollection was thrown.
or:
The designer loader did not provide a root component and has not indicated why
Usually the way to solve this is to open another instance of Visual Studio with the same project, attach the debugger to the other Visual Studio and try to open the form.
However, that does not seem to be working. The debugger does not break when the error is hit, and attempting to 'Break All' at any other point does not show me the source code and just the screen saying:
Your app has entered a break state, but there is no code because all threads were executing external code (typically system or framework code).
Attempting to put break points also results in:
The breakpoint will not currently be hit. No symbols have been loaded for this document
Am I missing a setting? Incorrect Setup?
I have been battling this for half a day and thoroughly search the interwebs with no luck thus far. My designer is also fairly complex and lengthy which means trial and error is an absolute last ditch option.
First attempt to resolve:
you may have tried it already. Right click the Solution in solution explorer, click "clean solution", this deletes all the compiled and temporary files associated with a solution.
Do a rebuild of the solution and try to debug again.
Second attept to resolve:
Start debugging, as soon as you've arrived at a breakpoint or used
Debug > Break All, use Debug > Windows > Modules. You'll see a list of all the assemblies that are loaded into the process. Locate the one you want to get debug info for. Right-click it and select Symbol Load Information. You'll get a dialog that lists all the directories where it looked for the .pdb file for the assembly. Verify that list against the actual .pdb location. Make sure it doesn't find an old one.
In normal projects, the assembly and its .pdb file should always have been copied by the IDE into the same folder as your .exe. The bin\Debug folder of your project. Make sure you remove one from the GAC if you've been playing with it.
third attept to resolve:
Disable the "Just My Code" option in the Debug/General settings.
there are might be other causes to your problem, i picked them from here. you may try other solution to try resolve your issues. Fixing "The breakpoint will not currently be hit. No symbols have been loaded for this document."

Change intellisense autocomplete for Try

When you type try and hit enter, it automatically types out
Try
Catch excError As Exception
WriteLog(excError)
End Try
This is not a snippet, I've looked. The snippet version has ApplicationException instead of Exception. Does anyone know where this is stored so I can change it?
You did not identify what version of Visual Studio, however here is how to modify the default Try/catch code snippets in Visual Studio Community 2015:
Tools -> Code Snippets Manager -> Language [Choose desired language in drop down] -> Code Patterns -> Error Handling
Highlight the desired code snippet and take note of the value in the location textbox above the split panel. Close Visual Studio as the .snippet file is most likely in use with Visual Studio open. Navigate to the path listed in the location text box and open the .snippet file with your favorite text editor. The .snippet file is a xml file; the actual code that is inserted by Intellisense is contained in the <Code><!CDATA[[]]></Code> node at the end of the file. Modify the code in within the CDATA block to what you wish Intellisense to insert for that code snippet and save the file.
Here is what the default <Code><!CDATA[[]]></Code> node should look like in the default Visual Basic Try/Catch snippet:
<Code Language="VB" Kind="method body"><![CDATA[Try
Catch ex As $ExceptionType$
End Try]]></Code>

Visual Studio 2013 Breakpoint Issue with Razor

For some reason, I can't set a breakpoint in #functions when using Visual Studio 2013. Here's an example:
However, the same kind of breakpoint works in Visual Studio 2012:
If you move the #functions block up to the top of the razor page in VS2013 you can set a breakpoint in #functions once again.
You cannot set a breakpoint in #functions if the block is somewhere in the HTML.
Anyone know why? Maybe a bug? This is a big inconvenience if you're migrating an web app from MVC4 or earlier where #function blocks appear in the HTML.
This seems like a known issue. See reported bug in MS Connect.
Description:
"After my upgrade to VS 2013, I am no longer able to debug javascript within MVC razor files. "
http://connect.microsoft.com/VisualStudio/feedback/details/807088/unable-to-debug-javascript-from-the-vs-2013-ide-unable-to-set-breakpoint
I had all of the same issues with "This not a valid location for a breakpoint", and I also had no code highlighting or intellisense on any of the Razor code. None of the solutions I could find resolved it. Primarily because my issue was due to a really dumb oversight on my part, but just in case anyone finds themselves here and have made the same mistake, I thought I'd share it.
If you did not physically create the view yourself in Visual Studio, like if it was created with a NuGet package (Umbraco in my case), or if you opened an existing solution that isn't yours...The view may not be included in the project. You may see something like this
Notice that the Homepage.cshtml file is in there and I can edit it, compile it, render it etc. But I could not insert a breakpoint anywhere. Right clicking on the file and Selecting "Include In Project" was the fix for me.
What worked for me was Excluding the file then Including it again. Picked up the Breakpoints straight away.
Hope it helps!
What helped me overcome this issue was enabling the "ASP.NET" option in the project-properties. See the screenshot:

Intellisense not working for XAML in VS2012 and only partially in Blend

I'm trying to get RC of Visual Studio 2012 working for XAML files. I can't seem to get any XAML Intellisense and the option within Tools is greyed out.
I've also tried to run the solution using Blend, however I only get Intellisense for custom controls such as telerik then.
When ever I drag controls onto the design surface I get an "Object reference not set to an instance of an object" exception but the control is still added to the surface.
I've read that this was a bug within VS11 and was fixed with in the Visual Studio 2012 RC.
I've created a new Silverlight Application and the intellisense is working so i'm wondering if its an issue with how my projects are set up.
I have all of my Styles within a separate themes project, which is referenced by other all other projects. Within the designer these references show up as errors but when the application runs they are resolved fine.
Would unresolved resources at design time affect Intellisense?
Click "Build -> Clean Solution", then "Build -> Build Solution". ("Rebuild Solution" alone doesn't work.) [Source]
If you have a reference to any of the expression blend dlls for interactions and you are using silverlight5 you will need to update the following dlls:
Microsoft.Expression.Controls.dll
Microsoft.Expression.Effects.dll
Microsoft.Expression.Interactions.dll
System.Windows.Interactivity.dll
Blend + SketchFlow Preview for Microsoft Visual Studio 2012
http://www.microsoft.com/en-us/download/details.aspx?id=30702
Ref Location:
C:\Program Files (x86)\Microsoft SDKs\Expression\Blend\Silverlight\v5.0\Libraries
Exact same problem here, using WPF.
In my case, removing:
<Page.Resources>
<vm:AnyViewModel x:Key="anyViewModel" />
</Page.Resources>
Solve my problem...
One known cause of XAML Intellisense failure is if System.Windows.Controls.Toolkit is one of the project references. I've seen where deleting that reference instantly fixes the problem. The problem is described in the comments of this Connect bug for VS2012 Beta, but it applies to the RC with the July update as well.
I've found that some xaml designers for a control have this issue, where other controls are just fine.
The problem (in my case) seems to be if parameters are null or events call uninitialized singletons. Something the designer gives you a stack trace and other timers renders with no problem.
I've found by changing the back-end code for pages that don't have Intelli-sense to include DesignerProperties always fixes the issue (in my cases).
public Homing()
{
InitializeComponent();
if (DesignerProperties.GetIsInDesignMode(this))
return;
// some other code here that may have uninitialized members
}
t
I'm not sure if I had the same problem, but Intellisense mysteriously stopped working for me within a XAML file. I tried cleaning the build as someone suggested, but that didn't work.
After I restarted Visual Studio 2013, the Intellisense in the XAML page started to work again.

VS 2010 Error Opening Design View

There is no editor available for 'file path here'. Make sure the application for file type (.vb) is installed.
This is the error that I get when I try to open a project I did a while back in VB. I tried a C# project and I can open the form for viewing fine, but for some reason VB won't work? Any ideas? I really don't want to do a repair on the whole application as it takes a while and I'm not even sure I have the ISO right now.
Check the compile mode of the object. If it is not set to "compile" then VS gets a bit weird about opening it up.