Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Microsoft.VisualBasic missing namespace

Microsoft.VisualBasic missing namespace

Scheduled Pinned Locked Moved C#
helpgraphicsquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Speedular
    wrote on last edited by
    #1

    Dear All I've been trying to code a code that record the users' voice from the mic but I seem to get stuck in some portion in which it keep showing me the error that the Microsoft.visualbasic.devices is missing? any help here is my code incase the problem is on my code

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using Microsoft.VisualBasic.Devices; //My problem is here
    using Microsoft.VisualBasic;
    using System.Runtime.InteropServices;

    namespace WindowsApplication1
    {

    public partial class Form1 : Form
    {
    
        \[DllImport("winmm.dll", EntryPoint = "mciSendStringA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)\]
        private static extern int mciSendString(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback);
    
        public Form1()
        {
            InitializeComponent();
        }
    
        private void Form1\_Load(object sender, EventArgs e)
        {
    
        }
    
        private void Record\_Click(object sender, EventArgs e)
        {
            // record from microphone
            mciSendString("open new Type waveaudio Alias recsound", "", 0, 0);
            mciSendString("record recsound", "", 0, 0);
        }
    
        private void SaveStop\_Click(object sender, EventArgs e)
        {
            // stop and save
            mciSendString("save recsound c:\\\\record.wav", "", 0, 0);
            mciSendString("close recsound ", "", 0, 0);
            Computer c = new Computer();
            c.Audio.Stop();
        }
    
        private void Read\_Click(object sender, EventArgs e)
        {
            Computer computer = new Computer();
            computer.Audio.Play("c:\\\\record.wav", AudioPlayMode.Background);
        }
    
        
    }
    

    }

    0 S 2 Replies Last reply
    0
    • S Speedular

      Dear All I've been trying to code a code that record the users' voice from the mic but I seem to get stuck in some portion in which it keep showing me the error that the Microsoft.visualbasic.devices is missing? any help here is my code incase the problem is on my code

      using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.Data;
      using System.Drawing;
      using System.Text;
      using System.Windows.Forms;
      using Microsoft.VisualBasic.Devices; //My problem is here
      using Microsoft.VisualBasic;
      using System.Runtime.InteropServices;

      namespace WindowsApplication1
      {

      public partial class Form1 : Form
      {
      
          \[DllImport("winmm.dll", EntryPoint = "mciSendStringA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)\]
          private static extern int mciSendString(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback);
      
          public Form1()
          {
              InitializeComponent();
          }
      
          private void Form1\_Load(object sender, EventArgs e)
          {
      
          }
      
          private void Record\_Click(object sender, EventArgs e)
          {
              // record from microphone
              mciSendString("open new Type waveaudio Alias recsound", "", 0, 0);
              mciSendString("record recsound", "", 0, 0);
          }
      
          private void SaveStop\_Click(object sender, EventArgs e)
          {
              // stop and save
              mciSendString("save recsound c:\\\\record.wav", "", 0, 0);
              mciSendString("close recsound ", "", 0, 0);
              Computer c = new Computer();
              c.Audio.Stop();
          }
      
          private void Read\_Click(object sender, EventArgs e)
          {
              Computer computer = new Computer();
              computer.Audio.Play("c:\\\\record.wav", AudioPlayMode.Background);
          }
      
          
      }
      

      }

      0 Offline
      0 Offline
      0x3c0
      wrote on last edited by
      #2

      Stop using the Computer class, and use the same instance of a SoundPlayer class instead

      S 1 Reply Last reply
      0
      • S Speedular

        Dear All I've been trying to code a code that record the users' voice from the mic but I seem to get stuck in some portion in which it keep showing me the error that the Microsoft.visualbasic.devices is missing? any help here is my code incase the problem is on my code

        using System;
        using System.Collections.Generic;
        using System.ComponentModel;
        using System.Data;
        using System.Drawing;
        using System.Text;
        using System.Windows.Forms;
        using Microsoft.VisualBasic.Devices; //My problem is here
        using Microsoft.VisualBasic;
        using System.Runtime.InteropServices;

        namespace WindowsApplication1
        {

        public partial class Form1 : Form
        {
        
            \[DllImport("winmm.dll", EntryPoint = "mciSendStringA", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)\]
            private static extern int mciSendString(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback);
        
            public Form1()
            {
                InitializeComponent();
            }
        
            private void Form1\_Load(object sender, EventArgs e)
            {
        
            }
        
            private void Record\_Click(object sender, EventArgs e)
            {
                // record from microphone
                mciSendString("open new Type waveaudio Alias recsound", "", 0, 0);
                mciSendString("record recsound", "", 0, 0);
            }
        
            private void SaveStop\_Click(object sender, EventArgs e)
            {
                // stop and save
                mciSendString("save recsound c:\\\\record.wav", "", 0, 0);
                mciSendString("close recsound ", "", 0, 0);
                Computer c = new Computer();
                c.Audio.Stop();
            }
        
            private void Read\_Click(object sender, EventArgs e)
            {
                Computer computer = new Computer();
                computer.Audio.Play("c:\\\\record.wav", AudioPlayMode.Background);
            }
        
            
        }
        

        }

        S Offline
        S Offline
        sohighthesky
        wrote on last edited by
        #3

        Project-Add Reference- in the .Net Option Find Micorsoft.VisualBasic and Add it to the Reference you will find you can using the namespace now;

        1 Reply Last reply
        0
        • 0 0x3c0

          Stop using the Computer class, and use the same instance of a SoundPlayer class instead

          S Offline
          S Offline
          Speedular
          wrote on last edited by
          #4

          I'm not familiar with that class really; thankx for your help I appreciate it

          0 1 Reply Last reply
          0
          • S Speedular

            I'm not familiar with that class really; thankx for your help I appreciate it

            0 Offline
            0 Offline
            0x3c0
            wrote on last edited by
            #5

            The SoundPlayer class is new to the .net framework, version 2.0. It provides the StartAsync and Stop methods. Put it as a variable in the SaveStop_Click and the Read_Click voids, and instantiate it. Then, just call the methods. Overall, it would look like this:

            private void SaveStop_Click(object sender, EventArgs e)
            {
            //Your mciSendString stuff goes here
            SoundPlayer player = new SoundPlayer();

            player.Stop();
            

            }

            private void Read_Click(object sender, EventArgs e)
            {
            SoundPlayer player = new SoundPlayer(@"C:\record.wav");

            player.PlayAsync();
            

            }

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups