- ago

In wealth-lab 6, sounds could be played with the SoundPlayer [using System.Media]. However in wealth-lab 8, the following error is occurring

The type or namespace name ‘Media” does not exist in the namespace ‘System’ (are you missing an assembly reference?).

When I look in the .Net Framework Assemblies list there is no reference for System.Media.
0
446
Solved
7 Replies

Reply

Bookmark

Sort
- ago
#1
https://stackoverflow.com/questions/42845506/how-to-play-a-sound-in-netcore

Also, haven't classes from System.Media migrated into System.Windows.Extensions external assembly, downloadable from Nuget?
https://www.nuget.org/packages/System.Windows.Extensions/
0
Best Answer
- ago
#2
Yes the System.Media has migrated however when I asked the question at the time I did not know that.

Also the references for both the System.ComponentModel.Primitives and the System.Windows.Extenisons assemblies are required.
1
- ago
#3
In Assembly Reference tool, I checked both:
System.Windows.Extensions
and
System.ComponentModel.Primitives

and get the error:
The type or namespace name 'Extensions' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?)

Is the Assembly Reference tool a wrapper for NuGet?
Or is there a Nuget access from within WL8?

Thanks!
0
- ago
#4
QUOTE:
and get the error:
The type or namespace name 'Extensions' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?)

I totally don't understand. From Visual Studio 2022, you installed System.Windows.Extensions using NuGet as a VS tool (via the VS Tools menu), correct? And then you added a VS reference to System.Windows.Extensions in your Visual Studio project, correct?

And now you're saying your Visual Studio project can't find the System.Windows.Extensions you just installed?

WL has nothing to do with NuGet, and it won't link to libraries downloaded by NuGet. But if you build a Visual Studio project for WL that links to a NuGet library you downloaded (such as System.Windows.Extensions), everything will get linked together in the Project build and manifest. If you know another way to link them together without VS, then you know more than me.
0
- ago
#5
QUOTE:
I totally don't understand. From Visual Studio 2022,

No, he uses Tools > Assembly References in WL8 as implied.
0
- ago
#6
QUOTE:
No, he uses Tools > Assembly References in WL8 as implied.

Is it possible to get that non-VS approach to work? Is there a binding or manifest--somewhere--to get the OS to dynamically load an external library without VS specifically creating such a link binding for loading it? If he places the System.Windows.Extensions.dll library in the WL install folder, will the OS loader automatically find it?

This question is going to come up, so can I ask if he could call the .NET 6.7 framework for his audio needs instead of the .NET 8.X framework that's missing the audio component he wants? Or would that create audio conflicts? Would the WL development team support such a mixed configuration? (Yes, we know that's not ideal or recommended.... DLL hell.)
0
- ago
#7
The following test code (way below) works. In my WL8 assembly references I have System.ComponentModel.Primitives and System.Windows.Extensions checked. If your code is using System.Windows.Extensions try getting rid of that using. My WL8 app folder has the following Microsoft and System DLLs, and I don't see anything special there that I copied into that folder, but I could be wrong.

CODE:
Microsoft.Bcl.AsyncInterfaces.dll Microsoft.CodeAnalysis.AnalyzerUtilities.dll Microsoft.CodeAnalysis.CSharp.dll Microsoft.CodeAnalysis.CSharp.Features.dll Microsoft.CodeAnalysis.CSharp.Scripting.dll Microsoft.CodeAnalysis.CSharp.Workspaces.dll Microsoft.CodeAnalysis.dll Microsoft.CodeAnalysis.Elfie.dll Microsoft.CodeAnalysis.Features.dll Microsoft.CodeAnalysis.Scripting.dll Microsoft.CodeAnalysis.VisualBasic.dll Microsoft.CodeAnalysis.VisualBasic.Features.dll Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll Microsoft.CodeAnalysis.Workspaces.dll Microsoft.Data.SqlClient.dll Microsoft.Data.SqlClient.SNI.dll Microsoft.DiaSymReader.dll Microsoft.Extensions.DependencyInjection.Abstractions.dll Microsoft.Extensions.Logging.Abstractions.dll Microsoft.Extensions.Logging.dll Microsoft.Extensions.Logging.xml Microsoft.Identity.Client.dll Microsoft.IO.RecyclableMemoryStream.dll Microsoft.Web.WebView2.Core.dll Microsoft.Web.WebView2.WinForms.dll Microsoft.Web.WebView2.Wpf.dll Microsoft.Win32.SystemEvents.dll System.CodeDom.dll System.Collections.Immutable.dll System.ComponentModel.Primitives.dll System.Composition.AttributedModel.dll System.Composition.Convention.dll System.Composition.Hosting.dll System.Composition.Runtime.dll System.Composition.TypedParts.dll System.Data.Common.dll System.Diagnostics.DiagnosticSource.dll System.Drawing.Common.dll System.IO.Packaging.dll System.IO.Pipelines.dll System.Management.dll System.Reactive.dll System.Runtime.Numerics.dll System.Text.Encodings.Web.dll System.Text.Json.dll System.Threading.Channels.dll


CODE:
using WealthLab.Backtest; using System; using System.Media; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript2 { public class MyStrategy : UserStrategyBase { //create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars) { } //execute the strategy rules here, this is executed once for each bar in the backtest history public override void Execute(BarHistory bars, int idx) { } public override void BacktestComplete() {          SoundPlayer player = new(@"C:\Windows\Media\ring06.wav");          player.Play();       } } }
0

Reply

Bookmark

Sort