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. go-客户信息关系系统

    客户信息关系系统 项目需求分析 1) 模拟实现基于文本界面的< 客户信息管理软件>. 2) 该软件能够实现对客户对象的插入.修改和删除(用切片实现),并能够打印客户明细表 项目的界面设计 ...

  2. jpa分页

    法一(本地sql查询,注意表名啥的都用数据库中的名称,适用于特定数据库的查询) public interface UserRepository extends JpaRepository<Use ...

  3. Feign自动装配原理

    spring.factories 按照以往的惯例,在研究源码的时候,我们先看一下spring.factories文件下自动装配的类FeignAutoConfiguration,其中比较重要的东西有这么 ...

  4. Typescript基础(4)——接口

    前言 今天继续typescript的学习,开始ts接口部分的学习. 接口 接口的理解 首先,我们谈论一下现实生活中的接口.比如生活中常用的插座接口,有些插头是三孔插座的,有些是两孔插座的.插座接口规定 ...

  5. 六个office免费学习的精品教程 office自学教程让你从小白到高手

    今天给大家分享六个免费学习的精品教程,包括了word,ppt,excel常用的办公三剑客,学会这三个让你办公无忧,也能让你靠这些技术找到一份好工作,这些office自学教程让你从小白到高手. 一.PP ...

  6. iOS UIPopoverView的使用

    UIViewController *contentViewController = [[UIViewController alloc] init]; contentViewController.vie ...

  7. BayaiM__ oracle函数_01

    BayaiM__ oracle函数_01   Oracle函数--------------------------------------------------------------------- ...

  8. fastdfs-nginx-module安装和配置

    fastdfs-nginx-module安装和配置 为什么要在fastdfs的storage端,安装fastdfs-nginx-module? 答案:https://www.cnblogs.com/l ...

  9. springboot 使用 jedis 连接 Redis 数据库

    1. 在 pom.xml 配置文件中添加依赖 <!-- redis 依赖 --> <dependency> <groupId>org.springframework ...

  10. 13.Java基础_数组内存图

    单个数组内存图 new int[3]: 在堆内存里申请一块空间存储int类型的变量(初始化时值都为0) int[] array: 在栈内存申请一块内存存储堆内存里数组的首地址 array[i]: 通过 ...