お知らせ

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Autodesk Community Tips- ADNオープン
Autodesk Community Tipsではちょっとしたコツ、やり方、ショートカット、アドバイスやヒントを共有しています。

C#のコンソールアプリケーションで、Inventor Apprentice Server のThumbnail取得でエラーが発生する

現象

C#のコンソールアプリケーションで、Inventor Apprentice Server のApprenticeServerDocument.Thumbnailプロパティにアクセスするとエラーが発生します。

回避方法はありますか。

 

解決策

C#のコンソールApplicationの場合、Main関数に[STAThread]属性を付加しSTAで動作するように指定することで、Thumbnailプロパティにアクセスできるようになります。

 

[STAThread]
static void Main(string[] args)
{

 

なお、VB.netの場合コンソールアプリケーションはデフォルトでSTAで動作する設定のため、[STAThread]属性を付加する必要はありません。

また、C#の場合でもWindows フォームアプリケーションの場合も[STAThread]属性を付加する必要はありません。