Describe the bug
I am trying to load the Rtsp package into a C#-based PowerShell module on MacOS Catalina. However, an error is thrown when I try to call the command in the PowerShell module.
Test-SampleCmdlet : Could not load file or assembly 'RtspClientSharp, Version=1.3.3.0, Culture=neutral, PublicKeyToken=af963665c791e92e'. The system cannot find the file specified.
At line:1 char:1
+ Test-SampleCmdlet
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Test-SampleCmdlet], FileNotFoundException
+ FullyQualifiedErrorId : System.IO.FileNotFoundException,PSRTSP.TestSampleCmdletCommand
In the ProcessRecord() method override, add some logic to connect to an RTSP stream
Run dotnet build to create your .NET DLL (PowerShell module)
In PowerShell Core, run Import-Module -Name /path/to/my.dll
The module imports successfully, but when running Test-SampleCmdlet -FavoriteNumber 1 I get an error
Expected behavior
The package should be loaded, without throwing errors.
Screenshots
Desktop (please complete the following information):
OS: MacOS Catalina
PowerShell Core 6.2.3
Browser n/a
Version [e.g. 22]
Additional context
Add any other context about the problem here.
Here is the full program code, for example:
using System;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using System.Threading;
using RtspClientSharp;
namespace PSRTSP
{
[Cmdlet(VerbsDiagnostic.Test,"SampleCmdlet")]
[OutputType(typeof(FavoriteStuff))]
public class TestSampleCmdletCommand : PSCmdlet
{
[Parameter(
Mandatory = true,
Position = 0,
ValueFromPipeline = true,
ValueFromPipelineByPropertyName = true)]
public int FavoriteNumber { get; set; }
[Parameter(
Position = 1,
ValueFromPipelineByPropertyName = true)]
[ValidateSet("Cat", "Dog", "Horse")]
public string FavoritePet { get; set; } = "Dog";
// This method gets called once for each cmdlet in the pipeline when the pipeline starts executing
protected override void BeginProcessing()
{
WriteVerbose("Begin!");
}
// This method will be called for each input received from the pipeline to this cmdlet; if no input is received, this method is not called
protected override void ProcessRecord()
{
var uri = new Uri("rtsp://10.5.4.23");
var connectionParameters = new ConnectionParameters(uri);
connectionParameters.RtpTransport = RtpTransportProtocol.TCP;
var token = new CancellationTokenSource();
using (var client = new RtspClient(connectionParameters)) {
var connect = client.ConnectAsync(token.Token);
connect.GetAwaiter().GetResult();
Console.WriteLine("Connected to RTSP stream");
}
WriteObject(new FavoriteStuff {
FavoriteNumber = FavoriteNumber,
FavoritePet = FavoritePet
});
}
// This method will be called once at the end of pipeline execution; if no input is received, this method is not called
protected override void EndProcessing()
{
WriteVerbose("End!");
}
}
public class FavoriteStuff
{
public int FavoriteNumber { get; set; }
public string FavoritePet { get; set; }
}
}
Describe the bug I am trying to load the Rtsp package into a C#-based PowerShell module on MacOS Catalina. However, an error is thrown when I try to call the command in the PowerShell module.
To Reproduce Steps to reproduce the behavior:
ProcessRecord()
method override, add some logic to connect to an RTSP streamdotnet build
to create your .NET DLL (PowerShell module)Import-Module -Name /path/to/my.dll
Test-SampleCmdlet -FavoriteNumber 1
I get an errorExpected behavior
The package should be loaded, without throwing errors.
Screenshots
Desktop (please complete the following information):
Additional context Add any other context about the problem here.
Here is the full program code, for example: