System.Threading.ThreadStateException: 'Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process.'

Thread exportThread = new Thread(() =>
{ });
exportThread.SetApartmentState(ApartmentState.STA);

Sets the apartment state of a thread before it is started.

[SecuritySafeCritical]
public void SetApartmentState(ApartmentState state);

SetApartmentState(ApartmentState state).Ensure that your Main function has STAThreadAttribute marked on it. This exception is only raised if a debugger is attached to the process的更多相关文章

  1. The App Life Cycle & The Main Function

    The App Life Cycle Apps are a sophisticated interplay between your custom code and the system framew ...

  2. [Cycle.js] Customizing effects from the main function

    How can we show one string on the DOM, and a completely different string on Console log? This lesson ...

  3. [Cycle.js] Main function and effects functions

    We need to give structure to our application with logic and effects. This lessons shows how we can o ...

  4. Main function

    Main function A program shall contain a global function named main, which is the designated start of ...

  5. 选择目录,选择文件夹的COM组件问题。在可以调用 OLE 之前,必须将当前线程设置为单线程单元(STA)模式。请确保您的 Main 函数带有 STAThreadAttribute 标记。 只有将调试器附加到该进程才会引发此异常。

    异常: 在可以调用 OLE 之前,必须将当前线程设置为单线程单元(STA)模式.请确保您的 Main 函数带有 STAThreadAttribute 标记. 只有将调试器附加到该进程才会引发此异常. ...

  6. 在可以调用OLE之前,必须将当前线程设置为单线程单元(STA)模式,请确保您的Main函数带有STAThreadAttribute

    导入导出功能,在调用ShowDialog时的错误,解决办法如下: WinForm窗体的入口点: /// <summary> /// 应用程序的主入口点. /// </summary& ...

  7. c# Clipboard.SetDataObject(bmp1) 在可以调用 OLE 之前,必须将当前线程设置为单线程单元(STA)模式。请确保您的 Main 函数带有 STAThreadAttribute 标记。 只有将调试器附加到该进程才会引发此异常

    c# Clipboard.SetDataObject(bmp1)  在可以调用 OLE 之前,必须将当前线程设置为单线程单元(STA)模式.请确保您的 Main 函数带有 STAThreadAttri ...

  8. Parse the main function arguments

    int main(int argc, char **argv) { std::string reportDir; std::string transURL; std::string visualEle ...

  9. Insert Function before and after main function

    Source code: 1: #include<stdio.h> 2: void myStartupFun (void) __attribute__ ((constructor)); 3 ...

随机推荐

  1. bootstrap table使用colResizable后表格不能自适应

    窗口缩小放大后,b表格不能自适应,table加了宽度没效果,求教

  2. Docker实用debug调试技巧锦集

    阅读约 20 分钟 『重用』容器名 但我们在编写/调试Dockerfile的时候我们经常会重复之前的command,比如这种docker run --name jstorm-zookeeper zoo ...

  3. Java生鲜电商平台-Spring Cloud微服务架构图

  4. 「SAP 技术」SAP MM 物料主数据利润中心字段之修改

    SAP MM 物料主数据利润中心字段之修改 近日,收到业务部门报的一个问题,说是MM02去修改物料的利润中心字段值,系统报错说物料库存存在,不让修改. 笔者查询了该物料的库存,当期库存并不存在.MMB ...

  5. vue-router Uncaught (in promise) NavigationDuplicated 错误

    使用 vue-router 编程式实现页面跳转 this.$router.replace({ path: '/pub' }); 出现错误如下图 原因:vue-router 在 3.1 版本之后把 th ...

  6. 5.JavaCC官方入门指南-概述

    一.前言   在最开始使用JavaCC的时候,从网上查询了许多资料,但是网上的资料水平是参差不齐的,走了许多弯路,不得已自己查阅了英文版官网文档.令我伤心的是最后我回过头来再看那些博客资料时,发现其实 ...

  7. bayaim_杀神_全民飞机大战

    bayaim_杀神_全民飞机大战 ------------------------ 系统:IOS QQ:7742469490 王者:30 游戏名:神 级别:98 装备:满鸡 + 新战魂+ 歼31 + ...

  8. jira Licenses更新步骤

    有时候我们不想花钱使用jira,那么只有通过一个月以续期的方式来使用jira.下面提供下自己实测的方式 1.获取License Key 登录地址:https://my.atlassian.com 登录 ...

  9. vs code切换中英文界面

    1. 在vs code的应用扩展中搜索这个插件: Chinese (Simplified) Language Pack for Visual Studio Code 这个插件,安装完毕重新加载即可生效 ...

  10. nginx是怎么处理http请求的

    nginx是怎么处理http请求的 参考:How nginx processes a request nginx first decides which server should process t ...