COM interop object throws InvalidCastException in one project but not in other

后端 未结 2 1306
一生所求
一生所求 2021-01-07 02:11

I have a COM object I imported in my test C# solution. Everything works fine and continues to do so.

Then I imported the same COM object in my actual solution and as

相关标签:
2条回答
  • 2021-01-07 02:46

    Since your COM component is working in a WinForm app but not in ASP.NET I'm thinking that you may be hitting some permission issues. Can you temporarily elevate the permissions that ASP.NET is running under (e.g. Administrator) and see if you can execute the component?

    0 讨论(0)
  • 2021-01-07 02:56

    The difference was in threading. The winform thread executed the code from the main thread, whereas the asp.net didn't. It was solved by explicitly running the COM in a STAThread.

    0 讨论(0)
提交回复
热议问题