Jump to content
LaunchBox Community Forums

.NET framework plugin references


Recommended Posts

I'm not sure if this belongs here or in the troubleshooting forum.  I've been working on a voice recognition plug-in for some time and it seems the 11.3 upgrade has broken the speech recognition functionality.  I'm getting the following exception when my code references System.Speech.  This is the exception: 

Could not load file or assembly 'System.Speech, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified. 

Here's the code, it was working in 11.2 so I think the change to .net core has caused this.  There's nothing special about the code here and it fails as soon as the method is invoked, before log message on the first line. 

        private bool CreateRecognizer()
        {
            try
            {
                Helpers.Log("Creating recognizer");

                List<string> titleElements = new List<string>(GameTitlePhrases.Keys);

                // add the distinct phrases to the list of choices
                Choices choices = new Choices();
                choices.Add(titleElements.ToArray());

                GrammarBuilder grammarBuilder = new GrammarBuilder();
                grammarBuilder.Append(choices);

                Grammar grammar = new Grammar(grammarBuilder)
                {
                    Name = "Game title elements"
                };

                // setup the recognizer
                Recognizer = new SpeechRecognitionEngine();
                Recognizer.InitialSilenceTimeout = TimeSpan.FromSeconds(5.0);
                Recognizer.RecognizeCompleted += new EventHandler<RecognizeCompletedEventArgs>(RecognizeCompleted);
                Recognizer.LoadGrammarAsync(grammar);
                Recognizer.SpeechHypothesized += new EventHandler<SpeechHypothesizedEventArgs>(SpeechHypothesized);
                Recognizer.SetInputToDefaultAudioDevice();
                Recognizer.RecognizeAsyncCancel();
            }
            catch(Exception ex)
            {
                Helpers.LogException(ex, "CreateRecognizer");
            }

            return (true);
        }

 

I tried copying System.Speech.dll into the plugins folder alongside my DLL but then I get another error when I load big box: 

An error occurred while attempting to load the plugin "C:\Users\...\Documents\LaunchBox\Plugins\System.Speech.dll"

Could not load the assembly 'System.Speech, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31f3856ad364e35, processorArchitecture=MSIL'. Reference assemblies should not be loaded for execution.  They can only be loaded in the Reflection-only loader context. (0x80131058)

It appears maybe it's trying to load System.Speech as a plugin?  I tried moving the DLL from the plugins folder over to the LaunchBox\Core folder but I was back to the original exception.  

I'm wondering if anyone has any suggestion.  Under .net framework and 11.2, I could reference System.Speech and it just worked.  Is there a place where .net framework references should go?  Any suggestion is greatly appreciated!

Link to comment
Share on other sites

Thanks Jason!  Is the BigBox plug-in API supporting plugins created in both .net framework and in .net core?  I am considering porting my plug-in to .net core but wasn't sure if it's supported.  I think it wasn't supported prior to 11.3.   

Link to comment
Share on other sites

1 minute ago, Fry said:

Thanks Jason!  Is the BigBox plug-in API supporting plugins created in both .net framework and in .net core?  I am considering porting my plug-in to .net core but wasn't sure if it's supported.  I think it wasn't supported prior to 11.3.   

Yes, you should be able to use either the .NET Framework or .NET Core.

  • Thanks 1
Link to comment
Share on other sites

Took me a bit to figure out how to add WPF user controls in a .net core class library project.  In case anyone is trying to do the same thing, you'll want to do this.  I think just the WindowsDesktop and <UseWPF> part.  Targeting netcoreapp3.1 is working fine

 
https://stackoverflow.com/questions/58836149/how-can-i-add-wpf-items-into-a-c-sharp-class-library-project-in-vs2019

 

Right-click on the class library project, choose "Edit project file" and copy the following contents into the .csproj file:

<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <UseWPF>true</UseWPF>
  </PropertyGroup>

</Project>

This should give you the ability to add WPF specific items to the project using the menus.

Edited by Fry
  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...