I get this error when I try to export or save this report file
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.
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using DevExpress.XtraReports.UI; namespace EMR.av.FormThamSo { public partial class frm_BAnoikhoa : Form { public frm_BAnoikhoa() { InitializeComponent(); } private void btn_inphieu_Click(object sender, EventArgs e) { string mbn = this.txtMBN.Text; Report.repBANoiKhoa rep = new Report.repBANoiKhoa(mbn); rep.CreateDocument(); rep.ShowPreviewDialog(); } } }
What am I missing or what was wrong? Will help me! Thank
rep.ShowPreviewDialog();
STAThreadAttribute
Main
[STAThread]
[STAThread] static void Main(string[] args) { ... }
[STAThread] static void Main() { Application.EnableVisualStyles(); DevExpress.Skins.SkinManager.EnableFormSkins(); SkinManager.Default.RegisterAssembly(typeof(DevExpress.UserSkins.BonusSkins).Assembly); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new ShareProject.frmDangNhap()); if (ShareProject.Bien.OKLogin) { ShareProject.Bien.Serial = 0; ShareProject.Bien.dondientu_ma_lien_thong_cskcb = "0145679"; ShareProject.Bien.dondientu_mat_khau_cskcb = "rqULrbcK0N"; ShareProject.Bien.dondientu_ma_bao_hiem_cskcb = "45679"; ShareProject.Bien.dondientu_ma_lien_thong_bacsi = "01002245HNO-CCHQ"; ePubLic.Cap_Do_Khoa_Du_Lieu =4; ePubLic.ma_benh_vien_khoa = "88888"; Application.Run(new Menu()); } }
Application.Run
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)