私たちはUWPでBrokeredComponentsを使用しようとしています。 TypeLoadExceptionまたはInvalidCastExceptionのいずれかを受信しています。BrokeredComponents TypeLoadとInvalidCastException
私たちは、BrokeredComponents内の他のクラスにアクセスできるように、一般クラスとして使用されるBrokeredComponentsHostというクラスを公開することを定義します。
各コンポーネントにGUIDを使用します。ここで
はBrokeredComponentsHostです:
namespace BrokeredComponents
{
[Guid(BrokeredComponentsHost.ClassId), ComVisible(true)]
public sealed class BrokeredComponentsHost : IBrokeredComponentFactory
{
internal const string ClassId = "881724C4-E330-40D5-BDA1-7D9F7C44FB7C";
internal const string FactoryInterfaceId = "1FA85472-5B0D-487C-B58E-F8BE9A89D470";
internal const string BarcodeScannerInterfaceId = "840F54D5-7AF7-4C31-91B0-BA274FCDD737";
public string LastError { get; set; }
public IPosScanner GetPosScanner()
{
return new PosScanner() { Host = this };
}
}
}
これはIBrokeredComponentsFactoryです:
namespace BrokeredComponents
{
[Guid(BrokeredComponentsHost.FactoryInterfaceId), ComVisible(true)]
public interface IBrokeredComponentFactory
{
IPosScanner GetPosScanner();
string LastError { get; set; }
}
}
そして、これはPosScannerとそのインタフェースです:
namespace BrokeredComponents
{
[Guid(BrokeredComponentsHost.BarcodeScannerInterfaceId), ComVisible(true)]
public interface IPosScanner : IPosDevice
{
bool DecodeData { get; set; }
bool DeviceEnabled { get; set; }
bool DataEventEnabled { get; set; }
bool AutoDisable { get; set; }
byte[] ScanData { get; }
}
}
我々が作成しようとすると新しいインスタンスのBrokeredComponentsHost(bcHost = new BrokeredComponents.BrokeredComponentsHost();
)それTypeLoadExceptionをスローします。
新しいクラス(ProcessExecutorクラスなど)を定義してすべてを再構築した後、BrokeredComponentsHostの新しいインスタンスを再度作成しようとすると、代わりにInvalidCastExceptionがスローされます。
私たちはicaclsです。/T/grant "すべてのアプリケーションパッケージ":RXおよびregsvr32 theproxy.dll。
誰もが同じ問題を抱えていて解決策を知っていますか?
ありがとうございました!
編集:私が受け取る正確なエラーメッセージが"Unable to cast COM object of type 'BrokeredComponents.BrokeredComponentsHost' to interface type 'BrokeredComponents.IBrokeredComponentFactory'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{1FA85472-5B0D-487C-B58E-F8BE9A89D470}' failed due to the following error: Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))."
私は、Windows 10、64ビット上で実行していますが、私のBrokeredComponentsプロジェクトは、Windows 8.1とBrokeredComponentsProxyは、VS 2013
編集2:私は持っていますTypeLoad例外が修正されました。公開クラスの拡張がAppxmanifestファイルで定義されていないというエラーでした。私はまだInvalidCastExceptionが発生しています。
>クラスが登録されていません。VSでプロキシスタブプロジェクトを管理者として再構築しましたか?これはこのCOM例外の状態です。 –
参照に正しいwinmdファイルを追加しましたか? 2つのwinmdファイルが必要です。そのうちの1つはプロジェクトへの参照として追加する必要があり、もう1つは実装であり、常にプロキシがある場所に移動する必要があります。 – Lance