Com Object That Has Been Separated From Its Underlying Rcw Cannot Be Used 追蹤

Legacy Poster

Good morning, with BarTender 9.3 I am try to terminate an instance of BarTender.Application in C# (.NET 2.0) via


I am receiving an exception, error message is

[quote]COM object that has been separated from its underlying RCW cannot be used[/quote].

This part of our application runs something like this (in an STA thread):

bool weAreNotQuitting = true;
bool printLabelNow = false;

BarTender.Application btApp
BarTender.Database btDb;
BarTender.Format btDoc;

btApp = new BarTender.ApplicationClass();
btDoc = btApp.Formats.Open("Labels.btw", false, "");

btDb = btDoc.Databases.GetDatabase(1);

btDoc.Printer = OurPrinter;

while (weAreNotQuitting)
btDb.OLEDB.SQLStatement = SelectStatement;
if (printLabelNow == true)
btDoc.PrintOut(false, false);

if (btApp != null)
btApp = null;

On btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges), we get

[quote]COM object that has been separated from its underlying RCW cannot be used[/quote].

Any ideas from the BarTender gurus?

Thanks in advance, and let me know if you need more info!

1 意見

Susan Chen
評論操作 永久連結

Hi, Renaissanz:

It look like you are using ActiveX integrate with Bartender, can you check the COM reference you add on the project? You can reference our white paper for more details.

I sugegst you try to use a simple open format and print program to see if the error happen and add on more functionalities afterwards.

** You might want to release COM object through System.Runtime.InteropServices.Marshal.ReleaseComObject(btApp) to correctly shutdown Bartender process.

Hope it helps.