LINQ errors

Error:

  • ‘First’ is not a member of ‘System.Data.EnumerableRowCollection(Of System.Data.DataRow)
  • “Definition of method ‘GroupBy’ is not accessible in this context”
  • ‘ToList’ is not a member of ‘System.Linq.Iqueryable(Of T)’

Solution:
Imports System.Linq
Also ensure that the DataSet is up to date. Use Run Custom Tool on the DataSet to ensure this.
Then ensure there is a reference to “System.Data.DataSetExtensions”.

See MSDN “How to Create a LINQ Project”
http://msdn.microsoft.com/en-us/library/bb546156.aspx

See MSDN 101 LINQ Samples
http://msdn.microsoft.com/en-us/vbasic/bb688088

Windows 7 SDK – Hilo

Cool sample http://code.msdn.microsoft.com/Hilo-0e6f10bf
http://msdn.microsoft.com/en-us/library/ff708696%28v=MSDN.10%29.aspx

Initially had error “cmd.exe exited with code 9009”
The code.msdn page where Hilo is in Q+A had this solution:

Hey, Try to open Properties for Annotator (right click) and select Configuration Properties –> General. Then set Platform Toolset to “Windows7.1SDK” (need to install Windows SDK 7.1 first). Good Luck
 
Then I had a message saying that the SDK was not installed. It seems that even though Windows SDK is installed with Visual Studio, I needed to install v7.1 to get Hilo sample working. The SDK did not install completely first time. But on trying to install it again, it suggested it was installed, did I want to Repair it, which I did, this seemed to work and Hilo then built and ran.

SSMS 2008 R2 is losing Intellisense after installing Visual Studio 2010 SP1

http://connect.microsoft.com/SQLServer/feedback/details/650569/ssms-2008-r2-is-losing-intellisense-after-installing-visual-studio-2010-sp1

Apply cumulative update to SQL Server 2008 R2

http://support.microsoft.com/kb/981356

 

Microsoft Visual Studio LightSwitch – Installation

There is a lot of web talk on problems with existing SQL installations before installing LightSwitch

  1. LightSwitch 2011 requires SQL Server Express to be installed. It is looking for SQLEXPRES instance.
  2. If you already have SQL Developer edition you may have a problem. I tried to trick it by adding an instance to SQL Developer named SQLEXPRESS. This got past the LightSwitch install.
  3. However still could not use the program because it also requires User Instances, which are not possible in Developer. So Removed my SQLEXPRESS instance. To do this > Programs and Features > Microsoft SQL Server 2008 R2 (64-bit) then Remove. Don’t panic it asks if you want to uninstall an instance, so you can leave previous instances on there.
  4. Then installed SQLExpress side-by-side with my developer edition. All OK
  5. LightSwitch 2011 good to go!

Reading Command line arguments in VB.NET

Nice clear entry at:

http://forum.codecall.net/visual-basic-tutorials/16661-reading-command-line-arguments-visual-basic-net.html

In Project > My Project > Publish > Options > Deployment
Uncheck “Use “.deploy” file extension

Now after publishing you will get the .exe file. If you create a shortcut to this .exe file you can add command line arguments to it as shown in the image below:

 Dim CommandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String) = My.Application.CommandLineArgs

 

For i As Integer = 0 To CommandLineArgs.Count - 1
     MessageBox.Show(CommandLineArgs(i))
Next

There maybe reasons why you may not want to uncheck this. Namely:

http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k(MICROSOFT.VISUALSTUDIO.PUBLISH.CLICKONCEPROVIDER.DIALOG.OPTIONS);k(TargetFrameworkMoniker-%22.NETFRAMEWORK%2cVERSION%3dV4.0%22)&rd=true

 

VS Bug on FormClosing datagridviewcomboboxcell value is not valid

Error message may be “Field called xxx does not exist”

Try this on Form closing

Private Sub frm_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
    Me.MyGridView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None
End Sub

I would hazard to suggest thatVisual Studio does not dispose of the datagridview in the correct sequence

This sometimes occurs when my personal code > SetUpDataGridView may programmatically set the AutoSizeRowsMode.

—–

This link http://social.msdn.microsoft.com/forums/en-US/winformsdatacontrols/thread/88c3adee-ed2a-41ee-9407-c3314588e08a/
Suggests it may be something to do with autosize, when there is a combobox created. The order of creation and setting may be important.

“If you autosize the column but have not provided the combo box column with a valid datasource or you haven’t yet added items to the combo box column’s items collection then you’ll get this error at startup because autosizing requires the cell’s FormattedValue to be requested. Requesting the FormattedValue of a combo box cell is where the check is done that may raise the data error exception you are seeing.

Set the autosize mode after you fill the combo box and things should be ok.

Mark Rideout – DataGridView Program Manager – Microsoft”

Or create the comboboxcolumn then clear the autosize modes > run > re-set the autosize mode.
Or programattically set the autosize after form has designer InitialiseComponent code has loaded.

Dataset Designer: Unable to find connection MyConn (MySettings)1 for object ‘MySettings’

 

Solved:
http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/08a48cad-619d-4421-b584-f2b5550ba6c5

Solution from Don,
“I had the same problem with one of my projects. If you open up the Dataset using the XML editor you should see a line near the top that looks like this:

<DataSourceDefaultConnectionIndex=1FunctionsComponentName=QueriesTableAdapterModifier=AutoLayout, AnsiClass, Class, PublicSchemaSerializationMode=IncludeSchemaxmlns=urn:schemas-microsoft-com:xml-msdatasource>

I changed the DefaultConnection Index from a 1 to a 0 and the problem went away. I suspect at one time I had two connections and one went away but the index was not updated.

<DataSourceDefaultConnectionIndex=0FunctionsComponentName=QueriesTableAdapterModifier=AutoLayout, AnsiClass, Class, PublicSchemaSerializationMode=IncludeSchemaxmlns=urn:schemas-microsoft-com:xml-msdatasource>”

Also other posts here may be useful:
In my particular case had too many connection strings and deleted one of them.

 

How to use windows api in VB.Net


'Imports System.Runtime.InteropServices

'Public Class aClass
' Private Shared Function FindWindow(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
' End Function
' Private Shared Function SetForegroundWindow(ByVal hWnd As IntPtr) As Boolean
' End Function
'End Class

How to Open a Process and Send Keys to that Process ( e.g. MS Word )

Following works fine opens document, ctrl + g = go to in word, book mark “StockControl”

Dim process1 As New Process
process1.StartInfo.FileName = String.Concat(My.Settings.DocumentationDirectory, My.Settings.HelpWordFile)
process1.Start()
process1.WaitForInputIdle()
'Dim hwnd = process.MainWindowHandle
Threading.Thread.Sleep(1000)
SendKeys.Send("^g")
SendKeys.Send("+{TAB}")
SendKeys.Send("b")
SendKeys.Send("{TAB}")
SendKeys.Send("StockControl")
SendKeys.Send("{ENTER}")
SendKeys.Send("{ESC}")

VS TFS Build