BrianPeek.com

A Compendium of Random Uselessness
in Search

Question re. Namespace (<Note for VB users>)

Last post Tue, Mar 6 2007 1:57 PM by Brian Peek. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • Sat, Feb 10 2007 3:16 PM

    • arlinjv
    • Top 25 Contributor
    • Joined on Sat, Feb 10 2007
    • Posts 4

    Question re. Namespace (<Note for VB users>)

    First of all, way cool project. I hope to do something just like that as soon as I get my skills advanced enough to understand what you've done.

    Brian, can you or anyone else explain why it is necessary to enclose the RemoteControlForm class in the Rccarvb namespace? I think this may pertain to a problem I am having in making Tony Northrop's x10 project work. (There seems to be a problem with the reference to the dll I need to import.)

    Thanks! (I'll be very happy to provide more details if any one is interested in helping a newbie out.)

  • Tue, Feb 13 2007 2:59 AM In reply to

    Re: Question re. Namespace (<Note for VB users>)

    I apologize for not responding sooner...I did not see the post in the active list of topics.

    I'm not 100% certain why the UI classes need to be explicitly wrapped in the namespace declaration.  Without it, the dssproxy command line task which runs that creates the .proxy dll as part of the build will fail.  I'm guessing that application, while using reflection to create the proxy dll is unable to match the non-namespaced objects properly inside the project.  This is not an issue in C# as all objects are automatically created with the namespace declaration by the IDE.

    If you can give me some more information on what's happening on your end I may be able to provide some more specific info...
  • Fri, Feb 16 2007 3:47 PM In reply to

    • arlinjv
    • Top 25 Contributor
    • Joined on Sat, Feb 10 2007
    • Posts 4

    Re: Question re. Namespace (<Note for VB users>)

    Hi Brian,

    Thanks so much for getting back to me.

    Here's the text of an email I sent to Tony Northrop:

    Hi Tony,

    First of all, thanks for all the cool topics you've presented. I am a big fan of your Home Hacking Projects book. Through your book I was able to create my own Perl based light controller (it gradually turns the lights on in my room, to help me get up at 4:30 to go to work.)

    I recently came across your Controlling lights article and am very excited to rebuild the application (with a lot more features and a cool "front end") in Visual Basic (to which I am a complete but enthusiastic newbie.) However, I am finding myself completely stymied with the references aspect of the project.

    Using the Solution Explorer I added the CraigsCreations.com.x10 dll as well as the SerialPort dll. However, upon cutting and pasting the x10 code I was immediately hit with an error indication by Intellisense. The error offered to fix the problem by switching the X10CM11aController object with the xm17 controller. When I did that I got the same error, but this time the IDE offered to switch me back to the xm11a controller. I got past this by going to the references tab on the properties page and selecting the check boxes that said anything about CraigsCreations. 

    Now I get a null exception error when it hits the New x10lamp code. Looking at the error details it seems that there is a problem with the SerialPort reference. I don't know if this helps, but SerialPort shows up in the Object Browser when 'view containers' is set, but not when 'view namespaces' is set.

    Here's my code so far:

     Imports CraigsCreations.com.X10
    Imports System.IO
    Imports System.IO.IsolatedStorage
    Public Class X10Control
    'current CM11 controller is on com1, bedroom light is housecode A unit 1
    Dim x10 As IX10Controller = New X10CM11aController(HouseCode.A, "COM1")
    ' Replace the unit codes in the following two lines with unit codes
    ' that you assign to your lamps
    Dim BedroomLight As X10Lamp = New X10Lamp(X10, 1) ' this is where it seems to hang up with the null exception error
     
     
    Private Sub btnON_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnON.Click
     
    End Sub
    End Class
     
    I really hope there's something very obvious I'm doing wrong. In any case any help would be greatly appreciated!
    Thank you,
    Arlin Vanderbilt
    __________________________________ 
     
    So, my hunch is that there is a namespace issue with the SerialPort dll which apparently is called by the X10Lamp class (method? I'm still learning the lingo.) By the way, The visual basic solution that Northrop wrote can be downloaded here. I copied the dll's from there. The original dll's were originally available from craigscreations.com., but the link seems to be broken now.  Any way, the SerialPort dll was written by 'Craig' to work with the x10 controls. I don't know if I could (or how, I would) substitute the standard SerialPort classes.
     
    Well, I hope I'm just doing something obviously wrong. And in any case, any help is really appreciated.
    Thanks,
    Arlin 
  • Fri, Feb 16 2007 3:57 PM In reply to

    • arlinjv
    • Top 25 Contributor
    • Joined on Sat, Feb 10 2007
    • Posts 4

    Re: Question re. Namespace (<Note for VB users>)

    BTW, if it would help, I could send a screen shot of the object browser for my project, I just couldn't figure out how to do so here.

    Arlin

  • Sat, Feb 17 2007 6:27 AM In reply to

    Re: Question re. Namespace (<Note for VB users>)

     Imports CraigsCreations.com.X10
    Imports System.IO
    Imports System.IO.IsolatedStorage
    Public Class X10Control
    'current CM11 controller is on com1, bedroom light is housecode A unit 1
    (--> lowercase "x10") Dim x10 As IX10Controller = New X10CM11aController(HouseCode.A, "COM1")
    ' Replace the unit codes in the following two lines with unit codes
    ' that you assign to your lamps

    Dim BedroomLight As X10Lamp = New X10Lamp((--> uppercase "X10") X10, 1) ' this is where it seems to hang up with the null exception error

     

    Look at my boldface comments above.  Is this how it looks in the actual code?  It appears that you should be passing your lowercase dim'ed x10 object to the X10Lamp object, but instead it's passing the X10 class imported on the top line.  Or something.

     
    Can you verify that this is what the code actually looks like and/or try fixing the lines in question?  Looking at the code in the project provided vs. this, this is the only thing I can come up with as to why it's not working as expected...  

  • Mon, Mar 5 2007 5:35 AM In reply to

    • arlinjv
    • Top 25 Contributor
    • Joined on Sat, Feb 10 2007
    • Posts 4

    Re: Question re. Namespace (<Note for VB users>)

    Brian,

    Thanks for the response. I didn't notice until now because I thought I would get an email response. I tried addressing your suggestion by changing 'x10' to something entirely different (xTen) in both locations but that didn't help.

     I did realize that it's hanging up on the first Dim line not the second as I indicated. (I figured this out by commenting out the second Dim statement)

     Here are the details of the NullReferenceException:

    System.NullReferenceException was unhandled
      Message="Object reference not set to an instance of an object."
      Source="SerialPort"
      StackTrace:
           at System.IO.Ports.SerialPort.CatchReceivedEvents(Object src, SerialEventArgs e)
           at System.IO.Ports.SerialStream.EndWaitForCommEvent(IAsyncResult ar)
           at System.Runtime.Remoting.Messaging.AsyncResult.SyncProcessMessage(IMessage msg)
           at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
           at System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(Object o)
           at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
           at System.Threading.ExecutionContext.runTryCode(Object userData)
           at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
           at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)

     

    As you can see, when the compiler hits  'Dim x10 As IX10Controller = New X10CM11aController(HouseCode.A, "COM1")' it throws the NullReference errror and refers to the SerialPort object reference in the error details. Now this is already getting past my meager understanding of VB but, seeing as the source of the exception was SerialPort it seems that the IX10Controller interface uses SerialPort internally, and it seems that the problem is with SerialPort.

    Well anyway I don't want to take advantage of your generosity with your time and I know this is probably something that can't be solved with out examining all the source information, but maybe I could just get your opinion on a couple aspects of this problem that I don't understand.

    First, is it significant that SerialPort shows up in the Object Browser when 'view containers' is selected but not when 'view namespaces' is selected?

    Also, in the properties of my references, I noticed that Specific Version is set to True but all the other references had this set to False. Is this significant?

     Thanks again for your help

     

  • Tue, Mar 6 2007 1:57 PM In reply to

    Re: Question re. Namespace (<Note for VB users>)

    Looking at the exception that's occurring, I can almost guarantee this has nothing to do with namespaces or the like.  The error is occurring down in the SerialPort class itself, waiting for data to be received on the port.

    My only theory is that either a) the hardware isn't configured correctly, b) it's on the wrong serial port, c) the code is opening the wrong port, or d) some other software has the port open before you're trying to open it.

     

Page 1 of 1 (7 items)
Copyright (C) 2008 Brian Peek
Powered by Community Server (Commercial Edition), by Telligent Systems