Hello,
I want to integrate an AWS.SQS service (to get notifications) into a plugin. I have tried the same code into an .net Framework application 4.8 but when I add it into the Init of the Background plugin I get this error:
System.MissingMethodException ‘Microsoft.Extensions.DependencyInjection.IServiceCollection Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions.AddAWSService(Microsoft.Extensions.DependencyInjection.IServiceCollection, Microsoft.Extensions.DependencyInjection.ServiceLifetime)’.
var builder = Host.CreateDefaultBuilder()
.ConfigureServices((hostContext, services) =>
{
services.AddHostedService<Worker>();
services.AddAWSService<IAmazonSQS>();
AWSOptions awsOptions = new AWSOptions
{
Credentials = new BasicAWSCredentials(AwsAccessId, AwsAccessSecret),
Region = RegionEndpoint.EUWest1,
};
services.AddDefaultAWSOptions(awsOptions);
services.AddTransient<IEventMessageHandlingService, EventMessageHandlingService>();
services.AddTransient<IUpdateMessageHandlingService, UpdateMessageHandlingService>();
});
var host = builder.Build(); //-> EXCEPTION
host.Run();
Could this be done with the MIPSDK? Should I use another Milestone technology to can connect to AWS SQS?
Thank you in advance for your help!
A guess is that the plugin doesn’t find the dll, maybe you haven’t distributed the dll with the plugin.
Hi Bo,
Thank you for your answer, I have a post-build event to copy both the .def and the .dll file. I have also checked that without that part of the code the plugin goes through StartAfterTokenAndConfigurationReady() without any problem but with the code I get:
I have also noticed (I don’t think it is related but I better ask) a lot of “access denied” exceptions
Exception thrown: ‘System.ServiceModel.Security.SecurityAccessDeniedException’ in System.ServiceModel.dll
Exception thrown: ‘System.ServiceModel.Security.SecurityAccessDeniedException’ in VideoOS.Platform.dll
Exception thrown: ‘System.ServiceModel.Security.SecurityAccessDeniedException’ in mscorlib.dll
Exception thrown: ‘System.ServiceModel.Security.SecurityAccessDeniedException’ in VideoOS.Platform.dll
Thank you for your help!
You say the dll file, in your case it must be multiple dll files, you should have also something containing the AWSService.
If you explore the RGBVideoEnhancement sample it is deployed with two dlls, in this case it something built by the plugin samples solution, in your case it would be a third party component.
https://doc.developer.milestonesys.com/html/index.html?base=samples/pluginsamples/rgbvideoenhancement/readme.html&tree=tree_1.html
My guess is that access denied are supposed to be there, I cannot imagine there is any relation to the MissingMethod exception.
Hi Bo!
Yes, the first time (or whenever I change a dependency) I copy the whole output bin folder, but for just debug I use the .def and plugin output dll. As I said I’m also able to run the plugin but only when it is not the AWS functions in it.
Any idea will be appreciated!
When you use third party libraries, they must be working in .Net Framework, the current version Smart Client uses 4.7.2. You must then place the dlls that the third-party libraries use in the plugin folder, same place as you deploy the plugin dll itself and the plugin.def file.
Please note, that you should not mix .Net Framework and .Net Core, we are not sure whether you are doing this, but if you are it could explain your issue.
That is all that there is to it, and I hope this information lets you solve the issue, because I don’t think there is much else, I can think of.
Hi Bo!
Thank your answer. I think it is a problem with AWS and it could not be compatible with the Framework 4.7.1, I’ve thinking on another approach, maybe it is a crazy idea:
- Use the AWS with net core
- Send the notifications using XProtect VMS API for events to register into Milestone
If this is possible how can I send these notifications? Could I create a GUID of and object event type in the plugin and send throught the API an event refering to that GUID?
I know I’m mixing the post with different things, sorry for that I can create a new one if it is necessary,
To me it sounds correct. If all you need to do is to raise events in XProtect you could use the Rest API for events.
https://doc.developer.milestonesys.com/html/index.html?base=samples/protocolsamples/eventsrestapipython/readme.html&tree=tree_3.html
https://doc.developer.milestonesys.com/mipvmsapi/api/events-rest/v1/
It is a pity if you cannot use the MIP Library because of the .Net Framework because I believe it gives you so much functionality easy to use, but maybe the above will be the better way for you depending on other libraries. If you have other questions to dive deeper into the functionality you need to make a successful integration, yes, perhaps you should start another thread asking a fresh question here in the forum.