none
object in VB vs C#

    Question

  • when I make a object in C# it work, but when I make this same object in c# it does not work

    SO my question is does C# do something to object to their Objects that VB does not?

    they are null when they are made 

    Sunday, April 06, 2014 6:23 PM

All replies

  • Can you show a small sample of code to illustrate your question?

    --
    Andrew

    Sunday, April 06, 2014 7:49 PM
  • In vb a newly created object that is not assigned a value would be nothing which is the same as c# null
    Sunday, April 06, 2014 8:09 PM
  • I doubt it.


    Hello. I'm old and retired. I like to program if you could call what I do programming. However I'd like to code for you! If you've got the dime then I've got the time. Call me, landline, @ BR-549.


    Sunday, April 06, 2014 8:31 PM
  • this is how it looks in C#:

    Sunday, April 06, 2014 9:10 PM
  • this is how the VB code looks:
    Sunday, April 06, 2014 9:22 PM
  • I been working this issue for 3 days at the posting below.  The issue is the Shared definition in VBnet is equivalent to Static in C#.  Not sure how to solve this problem.  I read a lot of articles on the web and the best solution says in VBnet to use an instance of the static/shared variable.  which means that C# is assuming the object is being passed by reference while VBnet is assuming the variable is being passed by reference.

    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/afdeb4ce-fc2f-4b3b-bf35-cde1a72d014d/#b843441b-6711-40ca-8b21-e69ebc239e85

    Maybe this change will work

    From :        Public Overrides Sub CreateAddressSpace(ByVal externalReferences As IDictionary(Of NodeId, IList(Of IReference)))
     

    To :        Public Overrides Sub CreateAddressSpace(ByRef externalReferences As IDictionary(Of NodeId, IList(Of IReference)))
     


    jdweng

    Sunday, April 06, 2014 9:37 PM
  • this is how the VB code looks:

    Your VB installation is configured with debugging options set to show all members for that object in the variables window.   There aren't any to show, hence the message.   The option doesn't apply to C#.  I suspect that simply closing the Locals window will make the error disappear, but to avoid it you need to change the debugging options.

    Sunday, April 06, 2014 9:49 PM
  • I got this error 

    Error 1 'Public Overrides Sub CreateAddressSpace(ByRef externalReferences As System.Collections.Generic.IDictionary(Of Opc.Ua.NodeId, System.Collections.Generic.IList(Of Opc.Ua.IReference)))' cannot override 'Public Overridable Sub CreateAddressSpace(externalReferences As System.Collections.Generic.IDictionary(Of Opc.Ua.NodeId, System.Collections.Generic.IList(Of Opc.Ua.IReference)))' because they differ by a parameter that is marked as 'ByRef' versus 'ByVal'.
    Sunday, April 06, 2014 9:50 PM
  • Acamar,

    THis is how it looks in  Locals window. 

    Sunday, April 06, 2014 10:00 PM
  • Acamar,

    You were right about that options  this is how it looks now:

    but it still does not look like  C# :

    It is missing  Keys and Values ..

    Do you know why that is ?

    Monday, April 07, 2014 4:39 PM
  • but it still does not look like  C# :

    It is missing  Keys and Values ..

    Do you know why that is ?

    It appears that there are language diffrences in the default attributes used by the debugger to display items in the watch and datatip windows, and perhaps there are also language-specific features in the type visualizers.

    It would seem that the debugger has some problem in visualizing an empty list for that type from VB code, so the option is provided to suppress all members.  That may be associated with type initialization processing, which does differ between VB and C# in some cases.    You could create a custom visualizer which did not require initialization when the list was empty, but it might be also possible (and much simpler) to turn the option back on but apply a DebuggerBrowsableState attribute to the variable to suppress it ('Never') or even to create a DebuggerTypeProxy to deal with this exact case.    The examples here:

    http://msdn.microsoft.com/en-us/magazine/cc163974.aspx

    are all in C#, so that isn't a lot of help for an issue that is VB-specific!

    Monday, April 07, 2014 10:30 PM
  • Acamar,

    it sound like you know what you are talking about, but i am lost. what do you mean but "but it might be also possible (and much simpler) to turn the option back on but apply a DebuggerBrowsableState attribute to the variable to suppress it ('Never') or "?

    Tuesday, April 08, 2014 2:16 PM
  • Acamar,

    it sound like you know what you are talking about, but i am lost. what do you mean but "but it might be also possible (and much simpler) to turn the option back on but apply a DebuggerBrowsableState attribute to the variable to suppress it ('Never') or "?

    Details are here:
    http://msdn.microsoft.com/en-us/library/vstudio/system.diagnostics.debuggerbrowsableattribute

    The discussion is here:
    http://msdn.microsoft.com/en-us/library/ms228992(v=vs.110).aspx

    The example is here:
    http://msdn.microsoft.com/en-us/library/vstudio/system.diagnostics.debuggerdisplayattribute

    Tuesday, April 08, 2014 9:51 PM
  • ACAmar :

    did you see this forum?

    http://social.msdn.microsoft.com/Forums/vstudio/en-US/afdeb4ce-fc2f-4b3b-bf35-cde1a72d014d/c-to-vb?forum=vbgeneral#ca60166e-a53a-44ca-9116-1eb240ff3575

    it is the other post that I made about this problem

    will working with DebuggerBrowsableState help with that the overall problem ?

     
    Wednesday, April 09, 2014 1:27 PM
  • it is the other post that I made about this problem

    We may have a misunderstanding.  Can you confirm that the error message only appears when you debug the program and stop it at that point?That is, the error only refers to the attempt by the debugger to display that value at that point in the program during debugging.  There is no run time error.

    If that is so then there is no 'problem' - it is simply a restriction on the debugger visualization capability for an uninitiized type.

    Wednesday, April 09, 2014 9:40 PM