Setting IntelliSense's default exception type - vb.net

In Visual Studio 2010 if I type th then press TAB twice, I will get:
Throw New ApplicationException("Exception Occured")
But in Visual Studio 2012 if I do the same thing, I will get:
Throw New ArgumentException("Exception Occured")
So the default exception type for IntelliSense has changed from ApplicationException to ArgumentException. Is this customizable? Is it possible to change the default intellisense exception type in Visual Studio 2012 to ApplicationException?
FYI plain vanilla Visual Studio without ReSharper / CodeRush / etc.

Simply edit VS2012Path\Vb\Snippets\1033\common code patterns\exception handling\ThrowanException.snippet
changing
<Default>ArgumentException</Default>
to
<Default>ApplicationException</Default>

Related

An unhandled exception occurred while processing the request SqlException

When I create a new project (web api) in Visual Studio 2019, I try running the project but I got the following error:
An unhandled exception occurred while processing the request.
SqlException: Invalid object name 'Books'.
Microsoft.Data.SqlClient.SqlCommand+<>c.b__169_0(Task result)
Did you check spelling in SqlDataReader? For me, I was misspelled. If the spelling is correct, any chance are you re-using the same name of an existing environmental variable for a different database on the same SQL Server? If the answer is yes it can be issue too.

F# SqlDataProvider, "The type initializer for 'Main' threw an exception.'

I have been attempting to use the SqlProvider type provider on several different databases where I work. In Visual Studio, intellisense for these different DBs (of types MS Access, SQL Server, and an ODBC connection) all work as shown below:
I've even tried it on the Northwind example database:
It does not matter the connection I actually choose, they seem to all result in 2 exceptions when the code is actually run:
System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for 'Main' threw an exception.
Source=SqlProviderTest2
StackTrace:
at Main.main(String[] _arg1) in C:\Users\***\source\repos\SqlProviderTest2\Program.fs:line 29
Inner Exception 1:
TypeInitializationException: The type initializer for '<StartupCode$SqlProviderTest2>.$Main' threw an exception.
Inner Exception 2:
FileLoadException: Could not load file or assembly 'System.Data.OleDb, Version=4.0.1.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
How is it possible that the intellisense can detect the DB but not work when the program is actually run? Is there a common fix for this?
(Using Visual Studio 2019 Professional, if that makes a difference.)

Microsoft ACE DatabaseEngine 2010 driver (12.0) Problem, after Windows 10 1909 Cumulative Updates (and later)

since cumulative Windows 10 1909 Updates are installed, I get following exception when accessing MS Access accdb.
: An external component raised an exception.
After reinstalling Microsoft ACE DatabaseEngine 2010 (OLEDB.12.0 ..), all works fine again.
What can I do about it?
Dim sel As String = "Select Notiz from T_TerminNotiz where ztrText=#ztrText and serNr=#serNr"
Using myConnection As New OleDbConnection(myConnStringX1)
myConnection.Open()
Using mySqlCmd As New OleDbCommand(sel, myConnection)
mySqlCmd.CommandType = CommandType.Text
mySqlCmd.CommandTimeout = myCmdTimeOut
mySqlCmd.CommandText = sel
mySqlCmd.Parameters.Clear()
mySqlCmd.Parameters.Add(New OleDbParameter("#ztrText", OleDbType.VarChar)).Value = strKlient
mySqlCmd.Parameters.Add(New OleDbParameter("#serNr", OleDbType.Integer)).Value = serNr
oRet = mySqlCmd.ExecuteScalar()
End Using
End Using
Microsoft announces (Known issues with Office and Windows 10) that included Office 2010, but did not specify any technical details for developers.
However, you did the best thing, considering that you will (anyway) provide DatabaseEngine 2010 Redist for the client.
Sometimes, the problem is
due to a mismatch between the build configuration platform of your
project and the Microsoft Access Database Engine which is installed on
your machine.
As stated in this answer [by/ Katia]. Hope this helps. Best of luck.
after some tests, I found following solution to my problem.
Installing Microsoft DatabaseEngine 2016.
I activated all OLE DB Services by adding it into configuration file xxx.config.
...
connectionString="Provider=Microsoft.ACE.OLEDB.16.0;Data Source=Table.accdb;Persist Security Info=True;OLE DB Services=-1;

Connecting to TFS Programmatically - Error: A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll

I have the following code which used to work and now no longer works:
collectionUri = New Uri(txtServerName.Text)
Dim tpc As New TfsTeamProjectCollection(collectionUri)
workItemStore = tpc.GetService(Of WorkItemStore)()
teamProject = workItemStore.Projects(txtProjectName.Text)
When my application hits the line: workItemStore = tpc.GetService(Of WorkItemStore)() I get the following error:
ArgumentException occurred
A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll
Additional information:
Requested value 'Information' was not found.
{System.ArgumentException: Requested value 'Information' was not found. at System.Enum.EnumResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument)}
I have uninstalled and re-installed Visual Studio 2013 ... same results. I have tried the application on another computer and it works just fine so I know my code is good.
I haven't touched this app in a few months so I'm not certain what would have changed. Any ideas?
Thanks.

DBNull error - 'System.InvalidCastException'

Using Visual Studio 2008 and generating .net 2.0 framework with VB.net for a web application.
I encountered a very strange problem currently. After I build a solution and click a link in a web page, I got an error message as following. The same thing happened when I tried to run in debug mode.
*************************************** ERROR Message ******************************************************
"An exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll but was not handled in user code"
"Additional information: Operator '=' is not defined for type 'DBNull' and string "". "
*******************************************************************************************************************
The problem part is simply as below in a vb file. The value of dataview(0)(“name”) is NULL and my_name is a variable string. The strange is thing I didn't change any code in this vb file. This vb file was built previously and used for a long time ago without any problem. It just suddenly happened today. I have this syntax all over the program without causing any problem. I have tried to restore the whole solution back to original but still have the problem.
Can anyone please advise why all the sudden and how to fix?
If dataview(0)(“name”) = my_name then …
Try to determine NULL value first ..
If NOT IsDBNull(dataview(0)(“name”)) Then
If dataview(0)(“name”) = my_name then
'codes here
End If
End If