Calculate Code Metrics – Troubleshooting

Project A references B
Code metrics work fine for B. Project A builds OK in Visual Studio. However “Calculate Code Metrics” on project produces error.

Message: An error occurred while calculating code metrics for target file ‘<My Assembly1 path>’ in project <My Assembly1>. The following error was encountered while reading module ‘<My Assembly2>’: Could not resolve member reference: <My Assembly3>.Models.IModel::get_FunctionTable.

SOLVED
It is possible that Code Metrics is using a different reference to Visual Studio. In my particular case my “Common Assemblies” folder had an older reference for Project B. By deleteing the reference from Common Assemblies, Code Metrics was forced to use the more up to date Project Reference, and then worked.

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.

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.

 

Crystal Reports specified DSN contains an architecture mismatch between the Driver and Application

Database error: MicrosoftODBC Driver Manager The specified DSN contains an architecture mismatch between the Driver and Application. (IES 10901) (WIS 10901)

On Windows 7 there are two ODBC. Probably want the first of these:
C:\Windows\SysWOW64 use against 32 bit data
C:\Windows\System32

However this could be mis-leading, as was the case this morning. It could be that a DSN is missing. Or perhaps missing from the correct ODBC.

SSRS Configuration – “user … does not have required permissions. Verify that .. and … UAC …

SOLVED

User ‘<server>\<username>’ does not have required permissions. Verify that sufficient permissions have been granted and Windows User Account Control (UAC) restrictions have been addressed.

“To get this resolved you need to start you Internet Explorer as Administrator -> Run as Administrator then open the url http://<Server name>/Reports this will take you to the “SQL Server Reporting Services” Home page
Click on the “Folder Settings” button.
Click on the “New Role Assignment” button.
Add the Group or user name: DOMAIN\USER_NAME, and permissions you have logged in as.
Click on Ok button.
This should resolve the issue.”

Entity Framework: WinForms databinding in EF4.1 – DBSet

Solved

Dim context As New SOPEntities
System.Data.Entity.DbExtensions.Load(context.Employees.Where(Function(f) f.Current = True).OrderBy(Function(g) g.FullName))
EmployeeBindingSource.DataSource = context.Employees.Local
ListBox1.DataSource = System.Data.Entity.DbExtensions.Tobindinglist(context.Employees.Local)
ListBox1.DisplayMember = “FullName”

Problem

‘local’ is not a member of ‘System.Data.Objects.ObjectSet(Of <entityname>)’

See http://wp.me/p17IS4-ih

 

Solved

Open the <Name>Model.edmx > Right click > Add code generation item…

Choose ADO.Net DbContext Generator. This has affect of changing the .edmx file Code Generation Strategy to “None” and creates a text template model and .Local now works.

Discussion

Uses EF4.1 EntityFramework.dll
Database first, then add code generation item to get T4 simpler classes and DBSet inherits DBContext
Initially could not work out how to get the Load method. See above for solution.
There is no MSDN VB.Net sample yet. The C# is more like context.Employees.Local.ToBindingList. So it took me a while to work out the syntax above.

Unsolved:
Also the FullName is now a computed column in the database. Was unable to work out how to do this in EF. It may come in the future as a “Model Defined Function”. Do not think this is a Scalar or Complex Type which is something else.
Unsolved:
For BindingSource to support complex filter it needs to support IBindingListView. Typically EF does not.

Links

Binding Objects to Controls
http://msdn.microsoft.com/en-us/library/gg197521(v=VS.103).aspx

Following is in C#
http://msdn.microsoft.com/en-us/library/gg197523(v=VS.103).aspx

Entity Framework: Error 111: Properties referred by the Principal Role…

The following error message may contain entity name or other project specific text

Error 111: Properties referred by the Principal Role must be exactly identical to the key of the EntityType referred to by the Principal Role in the relationship constraint for Relationship . Make sure all the key properties are specified in the Principal Role.

Solution upgarde to EF4.1 or higher.

 

Reference in the manifest does not match the identity of the downloaded assembly

SOLVED

Click-once does not install presenting error message:
“Reference in the manifest does not match the identity of the downloaded assembly …exe”

This could be if the referenced project is an executable, you may find that if you change the reference from a project reference to the executable file then try this may work.
Alternatively and if possible change the referenced project to  Class Library.

UPDATE 17/02/2012
Today I have extracted a Windows Forms from a main project into a smaller executable and referenced it from the main project.
I did a few things including above and then also it did not work until I had published the smaller project and it gained a certificate. Think the error was a validation error.