I have a simple project create with c# (.Net Core 6.0)
I create a AGIScript class with Asternet and recieve the data from asterisk server.
it's working well, As long as both are in the same project (exe project).
public void ListenToAgi()
{
var agi = new AsteriskFastAGI();
agi.MappingStrategy = new GeneralMappingStrategy(new List<ScriptMapping>()
{
new ScriptMapping() {
ScriptClass = "HI.agiSample.MyAgi",
ScriptName = "getvariable"
}
});
agi.Start();
}
MyAgi class is:
using AsterNET.NetStandard.FastAGI;
namespace HI.agiSample
{
public class MyAgi : AGIScript
{
public override void Service(AGIRequest request, AGIChannel channel)
{
string result = GetVariable("result");
}
}
}
My problem is, when I move the MyAgi class to ClassLibrary project, it doesn’t work; the AGI listener doesn’t start listening. But if both classes are in the same project (exe), it's working well.
NOTES:
namespaceis same in both project , Only theassemblyname is different.Project Aiswindows desktopapplication andProject BisClassLibrary.
One possible reason why your AGI listener is not working when you move the MyAgi class to a ClassLibrary project is because the AGI listener is instantiated and started in the executable project (Project A), but the MyAgi class is now in a separate ClassLibrary project (Project B).
By specifying the full namespace of the MyAgi class in the ClassLibrary project (Project B), you should be able to instantiate the AGI listener from the executable project (Project A) and still have access to the MyAgi class in the ClassLibrary project (Project B).
I hope this helps you get your AGI listener working again!