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

最后都变了- 提交于 2019-12-01 00:35:13

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.

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?

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!