1

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;
    }
2
  • have you tried calling your library with a web app (not a desktop app) with .net 4.6.2 (not .net core)? also have you checked the bitness (x86 vs x64) of apps? otherwise could you post some reproducing code Commented Sep 5, 2017 at 6:16
  • Ta for reply @Simon Mourier, have checked bitness. Everything lines up. Have tested with a .net 4.6.2 web app. Works fine as per desktop app. Commented Sep 5, 2017 at 23:43

1 Answer 1

1

Thanks for all that thought about this. Pretty much decided that I can't waste any more time on this right now. Since I'm pretty much limited to Windows anyway because of COM interactions, I've decided to just move back to using the .net 4.6.2 framework

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.