Click here to Skip to main content
15,902,447 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Entity framework : a query is not working as expected Pin
desanti5-Apr-19 10:36
desanti5-Apr-19 10:36 
GeneralRe: Entity framework : a query is not working as expected Pin
Dave Kreskowiak5-Apr-19 10:50
mveDave Kreskowiak5-Apr-19 10:50 
GeneralRe: Entity framework : a query is not working as expected Pin
desanti5-Apr-19 11:52
desanti5-Apr-19 11:52 
GeneralRe: Entity framework : a query is not working as expected Pin
Dave Kreskowiak5-Apr-19 12:59
mveDave Kreskowiak5-Apr-19 12:59 
GeneralRe: Entity framework : a query is not working as expected Pin
desanti5-Apr-19 13:45
desanti5-Apr-19 13:45 
GeneralRe: Entity framework : a query is not working as expected Pin
Eddy Vluggen5-Apr-19 21:23
professionalEddy Vluggen5-Apr-19 21:23 
GeneralRe: Entity framework : a query is not working as expected Pin
Richard Deeming15-Apr-19 8:20
mveRichard Deeming15-Apr-19 8:20 
QuestionTrying to create generic object: SOLVED Pin
mo14923-Apr-19 6:53
mo14923-Apr-19 6:53 
As usual, as soon as I post, if figure it out; sorry. Frown | :(
This
Me._Column = Activator.CreateInstance(GetType(T))()

Should be this
Me._Column = Activator.CreateInstance(GetType(T)).

However, now I have another problem; I'll work on this awhile.


I hope I am in the right group.

I have a Class that creates an xml file that currently works.
However, I would like to change the definition to define 1 of 2
generic types (T) when creating the file; Column1 or Column2. The code below is what
I have come up with through searches.
Everything compiles but when I create an instance of MyXmlDef I get this error.
'No Default Member Found for type 'Column1'

A search on the error says:
A late-bound index Get or Set call has been attempted.
Ensure that the object has a default property with a Get or Set, depending on which you are trying to make.

I have tried to define a Property for Column below but it doesn't fix the error.
I don't know what 'object' the error refers to.

Can someone help?
Thank you

' I am just showing the relevant code
' I have hardcoded this to Column1 to test
public Class MyXmlDef

<XmlElement("ColumnList")> _
Public _ColumnList As ColumnList(Of Column1)

Public Sub New()
Me._ColumnList = New ColumnList(Of Column1)
end sub

end Class

Class ColumnList(Of T)

<XmlElement("Column")> _
Public _Column As T

' This is test code to try and fix the error; it doesn't fix.
Public Property Column() As T
Get
Return Me._Column
End Get
Set(ByVal value As T)
Me._Column = value
End Set
End Property

Public Sub New()
' THis is the code I found on the internet to create an object from generic.
' However, it does not compile.
' Me._Column = Activator.CreateInstance(T)()

' This compiles but get the error described above for Column1.
' I do not know if this is valid or not.
Me._Column = Activator.CreateInstance(GetType(T))()
End Sub
End Class


Class Column1
<XmlElement("ProductName")> _
Public _ProductName As XMLProductName

' ... other XmlElments

Public Sub New()
'... initialize elements
end sub
End Class

Class Column2
<XmlElement("ProductName")> _
Public _ProductName As XMLProductName

' ... other different XmlElments

Public Sub New()
'... initialize elements
end sub

End Class

-- modified 3-Apr-19 13:40pm.
AnswerRe: Trying to create generic object Pin
Richard Deeming3-Apr-19 7:39
mveRichard Deeming3-Apr-19 7:39 
QuestionVisual Studio 2010 project open in Visual Studio 2019 when run there is a error failed to sign Pin
Didier Cauberghe3-Apr-19 4:54
Didier Cauberghe3-Apr-19 4:54 
AnswerRe: Visual Studio 2010 project open in Visual Studio 2019 when run there is a error failed to sign Pin
Mycroft Holmes3-Apr-19 12:18
professionalMycroft Holmes3-Apr-19 12:18 
GeneralRe: Visual Studio 2010 project open in Visual Studio 2019 when run there is a error failed to sign Pin
Didier Cauberghe4-Apr-19 3:49
Didier Cauberghe4-Apr-19 3:49 
QuestionForce entity framework to load new data from database without disposing the context Pin
desanti2-Apr-19 3:21
desanti2-Apr-19 3:21 
AnswerRe: Force entity framework to load new data from database without disposing the context Pin
Dave Kreskowiak2-Apr-19 4:23
mveDave Kreskowiak2-Apr-19 4:23 
GeneralRe: Force entity framework to load new data from database without disposing the context Pin
desanti2-Apr-19 7:40
desanti2-Apr-19 7:40 
GeneralRe: Force entity framework to load new data from database without disposing the context Pin
Dave Kreskowiak2-Apr-19 9:11
mveDave Kreskowiak2-Apr-19 9:11 
GeneralRe: Force entity framework to load new data from database without disposing the context Pin
desanti2-Apr-19 9:22
desanti2-Apr-19 9:22 
GeneralRe: Force entity framework to load new data from database without disposing the context Pin
Dave Kreskowiak2-Apr-19 11:24
mveDave Kreskowiak2-Apr-19 11:24 
GeneralRe: Force entity framework to load new data from database without disposing the context Pin
desanti3-Apr-19 5:01
desanti3-Apr-19 5:01 
GeneralRe: Force entity framework to load new data from database without disposing the context Pin
Dave Kreskowiak3-Apr-19 7:22
mveDave Kreskowiak3-Apr-19 7:22 
GeneralRe: Force entity framework to load new data from database without disposing the context Pin
desanti3-Apr-19 8:23
desanti3-Apr-19 8:23 
GeneralRe: Force entity framework to load new data from database without disposing the context Pin
Dave Kreskowiak3-Apr-19 8:57
mveDave Kreskowiak3-Apr-19 8:57 
GeneralRe: Force entity framework to load new data from database without disposing the context Pin
desanti3-Apr-19 9:40
desanti3-Apr-19 9:40 
GeneralRe: Force entity framework to load new data from database without disposing the context Pin
Dave Kreskowiak3-Apr-19 10:30
mveDave Kreskowiak3-Apr-19 10:30 
GeneralRe: Force entity framework to load new data from database without disposing the context Pin
desanti3-Apr-19 11:16
desanti3-Apr-19 11:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.