I have two projects. A .net core web project and a .net 4.6.2 class library. My class library wraps up required functionality from a external software package via com.
The com type I'm dealing with, I've added to the class library references so I can define strongly typed instances, this works fine.
Where my issue starts is certain properties and methods of this com library also return a System.__ComObject.
These return objects I've declared using Dynamic, so if my reading is correct, this means run-time binding is used to access properties and methods.
However, when calling my class library from my web api, I'm getting errors telling me that the properties/methods don't exist on System._ComObject. I can run the exact some calls to my class library form .net 4.6.2 desktop app no problems.
What am I doing wrong that is stopping my class library from being able to do the run time binding when called from a .net core project?
.NetCore Simple Scaffolded up controller
// GET: api/Job
[HttpGet]
public IActionResult Get()
{
try
{
//Call to static method Class Library
return new ObjectResult(Job.GetJobList();
}
catch (Exception ex)
{
return BadRequest(ex);
}
}
.Net 4.6.2 Class
public static List<Job> GetJobList()
{
List<Job> retVal = new List<Job>();
//Create Accounts instance - external software package
Accounts accounts = new Accounts()
accounts.Login();
dynamic accountsSettings = accounts.GetSettings();
//accountSettings Type = System.__ComObject
String systemPath = accountsSettings.SystemPath;
//Exception here: System.__ComObject does not contain definition for 'SystemPath'
//Other code here to build list of jobs
return retVal;
}