SendMessage(WM_SETTEXT..) API が呼び出されたときにエラーをスローするクライアント マシンで問題が発生しています。他の顧客のマシンとここにあるすべてのマシンで正常に動作します。スローされるエラーは System.Security.Permissions.SecurityPermission です。私はグーグルで調べましたが、理由についての言及は見つかりませんでした。hwnd が実際のウィンドウを指していない場合でも、私のテストではエラーは発生しません。どんな助けでも大歓迎です。
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, string lParam);
...
private void RegisterWithCaller()
{
if (this.hwndCaller != IntPtr.Zero)
{
if (FormMode.DELIVERY == this.formMode)
{
SendMessage(this.hwndCaller, WM_SETTEXT, 0, "hWndInvoiceDisplay=" + this.txtCommunicate.Handle.ToInt32().ToString());
}
else
{
SendMessage(this.hwndCaller, WM_SETTEXT, 0, "hWndBOLsDisplay=" + this.txtCommunicate.Handle.ToInt32().ToString());
}
}
}