Results 1 to 11 of 11

Thread: BC30456 'Computer' is not a member of [Solution / Project name].My

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2022
    Posts
    4

    BC30456 'Computer' is not a member of [Solution / Project name].My

    I'm using Visual Studio 2019 - Windows Form App - Visual basic - This is my code:
    Public Sub PlayBackgroundSoundFile()
    My.Computer.Audio.Play("C':\Sound.wav")
    End Sub
    I've used this Sub previously in other projects and it's worked fine but I've just created a new Solution / Project and I get this error message:
    BC30456 'Computer' is not a member of [Solution / Project name].My
    It seems such a simple issue but I can't fix it

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    109,268

    Re: BC30456 'Computer' is not a member of [Solution / Project name].My

    First things first, you have posted in the CodeBank forum, which is for sharing working code samples, not asking questions. I have notified the mods and they will move the thread. Please do not create a duplicate thread.

  3. #3
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    109,268

    Re: BC30456 'Computer' is not a member of [Solution / Project name].My

    As for the issue, which .NET version are you targeting? I'm guessing it's .NET 5.

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,880

    Re: BC30456 'Computer' is not a member of [Solution / Project name].My

    Welcome to VBForums!

    I have moved this thread from our "CodeBank - Visual Basic .NET" forum to our "Visual Basic .NET" forum

  5. #5

    Thread Starter
    New Member
    Join Date
    Nov 2022
    Posts
    4

    Re: BC30456 'Computer' is not a member of [Solution / Project name].My

    First: Sorry I posted my question in the wrong forum and thanks for moving it for me.
    Second: Sorry, I don't know which .NET version I'm targeting how do I tell? And which one should I be targeting? I'm just writing a very simple little Windows app.

  6. #6
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,187

    Re: BC30456 'Computer' is not a member of [Solution / Project name].My

    You would have selected the .NET version when creating the solution/project. To find out after the fact, open up the project's properties (Project > [Name] Properties) and under the Application tab, tell us what it says under Target framework.
    "Code is like humor. When you have to explain it, it’s bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  7. #7
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    109,268

    Re: BC30456 'Computer' is not a member of [Solution / Project name].My

    I suspect what's happened is that you have targeted .NET 5. I'm not sure but I don't think that all the My features had been reimplemented in .NET 5. If you upgrade to VS 2022 and target .NET 6 or 7 then I think you should be OK with that code. I don't think that you can target anything later than .NET 5 in VS 2019 but I could be wrong. The alternative is to target .NET Framework rather than .NET Core (.NET 5 and later are based on .NET Core). When you create a new project, all the project templates that target .NET Framework specifically say so in the name. If you want to target .NET Framework, it's a good idea to type "framework" in the filter box in the New Project dialogue to exclude other projects and ensure you don't select the wrong one.

  8. #8

    Thread Starter
    New Member
    Join Date
    Nov 2022
    Posts
    4

    Re: BC30456 'Computer' is not a member of [Solution / Project name].My

    Thanks for really helpful replies.
    I checked as you told me and found the target framework I had invoked was .NET Core 3.1
    The earlier project that was working ok used .NET Framework 4.5
    I have now changed my new project to use .NET Framework 4.7.2 - And it now works perfectly!
    I need to read up and understand what .NET Core and Framework is all about!!!
    Just one more thing, instead of using My.Computer.Audio.Play("C':\Sound.wav") I should really move Sound.wav to 'Resources' so that it installs when I publish the project. Any help with this would be gratefully received.
    Thanks again for all your help.

  9. #9
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,059

    Re: BC30456 'Computer' is not a member of [Solution / Project name].My


  10. #10
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    109,268

    Re: BC30456 'Computer' is not a member of [Solution / Project name].My

    You can also use the SoundPlayer class, which has no dependency on the VB My namespace.

  11. #11

    Thread Starter
    New Member
    Join Date
    Nov 2022
    Posts
    4

    Re: BC30456 'Computer' is not a member of [Solution / Project name].My

    Now got all working how I want, and also read up about .NET Core and Framework, so it's been a great learning curve.
    Thanks again, and signing off

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width