Entity framework designer “Type ‘ObjectParameter is not defined” with old code generation items

Errors:

  1. “Namespace or type specified in the imports ‘System.Data.Objects’ doesn’t contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure that the imported element name doesn’t use any aliases.”
  2. “Type ‘ObjectParameter is not defined” with old code generation items

 

The code generation item was created some years ago. Now whenever the myModel.context.tt is executed it puts “Imports System.Data.Objects” at the top of the Model.Context.vb file.

 

Solution

It provides a suggestion of “Change ‘System.Data.Objects’ to ‘System.Data.Entity.Core.Objects’ which is easy enough to do, only you will have to do it next time as well.

So do the change then actually copy the “Imports System.Data.Entity.Core.Objects”

into the Model.Context.tt file, so that next time it will generate correctly.

 

End.

 

MS Word 2013 ActiveDocument.MailMerge.OpenDataSource not available for reading on opening a document

A new PC has MS Office 2013 when the system still uses Office 2003 templates and vba code.

Error:

Don’t have actual text to hand, but something like:

“MailMerge.OpenDataSource is not available for reading”

 

Solution:

Programmatically change the view on open:

Private Sub Document_Open()
Me.ActiveWindow.View.Type = wdNormalView
End Sub

 

Found solution on web. Following was not the page, but similar

http://blogs.msmvps.com/wordmeister/2013/02/22/word2013bug-not-available-for-reading/

http://social.msdn.microsoft.com/Forums/expression/en-US/d68fe679-6a44-4437-b64a-ab6dfce4fa78/problem-with-activedocumentmailmergeopendatasource-read-only-words-documents-office-2013?forum=worddev

 

 

 

Visual Studio Extension Manager – Favourite Extensions

The extensions I find use are:

  1. NuGet
  2. Reference Assistant for Visual Studio 2010
    Remove unused references. In VS for VB, but not available in C#
  3. Language Convert
    Convert VB.Net to C#
  4. Search Work Items for TFS 2010

 

 

Index was out of range. Must be non-negative and less than the size of the collection. – On close form – DataGrid column

When closing a Windows Form on a button using Me.Close then get the following:

Error

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Solution

Tabs with Detail and List using a DataGridView, both

Had switched a BindingSource from a data table to a data source (object) which used a different field, so the DataGridView lookup column now had an invalid column.

Change to new column name and it will work.

End.

 

SQL Server hangs on drop foreign key

This actually happened on Azure during part of a SSIS SQL Server integration package, removal of key before delete and upload of data

Following post was very useful

http://weblogs.asp.net/jeffwids/lock-request-time-out-period-exceeded

To find sessions then

SELECT r.session_id, r.status, r.start_time, r.command, s.text,
r.wait_time, r.cpu_time, r.total_elapsed_time, r.reads, r.writes, r.logical_reads, r.transaction_isolation_level
,r.*
FROM sys.dm_exec_requests r
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) s

then Kill session id, but you cannot kill your own session, so open another session to do the kill

End.

WPF problem in visual studio generated file g.vb “Namespace or type..

 

This warning was in the Visual Studio generated file. Warning is:

Namespace or type specified in the Imports ‘SRS.WpfControlLibrary1’ doesn’t contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn’t use any aliases. …SRS.WPF.Controls\obj\Debug\ucDataDrivenDGButton.g.vb 15 9 SRS.WPF.Controls

I had renamed the project and the Assembly name and the root namespace.

I did a search for the “SRS.WpfControlLibrary1” and found some required fixes/changes. Although I do not remember its creation this project used a Themes\Generic.xaml with an incorrect namespace, so I changed that.

The Generic.xaml seems to be special and in the AssemblyInfo.vb there was an attribute

<Assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)>

I also cleaned and built the project after the Generic.xaml update and now all ok

 

Similar Error

With VB Project Namespace change the .g.vb file references the old namespace.

Solution

The xaml had

xmlns:my1=”clr-namespace: … old namespace

Updated this and saved (possibly build also) and the project and the problem went away

 

End.

 

WPF datagrid takes a long time to load

Scenario

myDataGrid is in a simple WPF Grid control where a RowDefinition has a Height=”*”

<Grid >
   <Grid.RowDefinitions>
   <RowDefinition Height=”*” />
</Grid.RowDefinitions>

And if myDataTable has a large row count then the following may ‘hang’ or take a long time to load on following code:

myDataGrid.ItemsSource = myDataTable.DefaultView

The issue is that if the DataGrid is in a control that has unlimited height then it will render the whole DataGrid.

 

Solution

Options to resolve this include:

  1. Changing the RowDefinition Height
  2. Add MaxHeight to the DataGrid, so <DataGrid x:Name=”myDataGrid” MaxHeight=”1000″ />

Performance is then fine.

With thanks to: http://stackoverflow.com/questions/3336921/unreasonable-wpf-datagrid-loading-time

End.

SQL Server – Take database offline hangs

With thanks to following and other web searches:

SQL Server – database “take offline” hangs

Scenario

New SQL Server on a new Azure VM, with a few new issues to learn from. I attempted to take a database offline but it hung.

Solution

USE master

SELECT resource_type, resource_associated_entity_id,
    request_status, request_mode,request_session_id,
    resource_description
    FROM sys.dm_tran_locks

--Find troublesome session and kill it.
--You cannot kill your own process, so you may need to start another session
KILL [SPID]

To take the database offline without waiting try this:

alter database DOTNETNUKE_EBC set offline with rollback immediate

To bring database online:

alter database DOTNETNUKE_EBC set online

 

End

 

Office upload center upload failed permission issue

 

Sometimes Office upload centre just stops working.

Sometimes with failed permission, sometimes with

“OneDrive for Business found a problem while accessing the Microsoft Office Document Cache and needs to repair it before it can continue.
As part of the repair a copy of the cache will be saved as a backup and a new cache will be created.”

See also: http://community.office365.com/en-us/f/172/t/238998.aspx on time 5/14/2014 10:58 PM

If required then:

  1. Stop syncing
    http://office.microsoft.com/en-us/support/stop-syncing-a-library-with-skydrive-pro-HA102850041.aspx
  2. Rename folder as backup in case you lose files
  3. Stop related services in Task Manager Resources, including Groove, MSOSync or similar
  4. Clear cache
    http://community.office365.com/en-us/f/148/t/161576.aspxBrowse to “C:\Users\username\AppData\Local\Microsoft\Office\Spw” and delete all the content. You will see that this is all related to groove, and spw equals SharePoint Workspace.Go to “C:\Users\username\AppData\Local\Microsoft\Office\15.0\OfficeFileCache” and also delete all content from this folder. This is where all the caching from your files are stored.
    Note : Just try to delete all, if one or two items cannot be deleted, that’s OK.
  5. Sync again
    It may or may not allow you to choose a location

 

http://community.office365.com/en-us/f/148/t/215635.aspx

 

 

Loading WPF User Control at runtime

Need to place the user control in a control that accepts content. My current favourite is a “ContentControl”.

Me.ContentCanvas.Content = userControlValue
Me.ContentCanvas.Content = Nothing

Some other controls require Add.

Beware that a StackPanel will expand to fit all content, so if you put a DataGrid and possibly a ListBox in there, there will be no scroll bar.