私はCOMアセンブリを持っています(私はいくつかのC#コードで参照しているcom1.dll)。私が参照を追加すると、参照ノードの下にInterop.com1.dllがあります。私がVisual Studioからアプリケーションを実行すると、次のコードがうまく動作します。私は、ビルドスクリプトから生成されたアセンブリを実行するとCOM例外: "SerializationException:入力ストリームが有効なバイナリ形式ではありません。開始内容..."
<tlbimp output="Interop.com1.dll" typelib="com1.dll" namespace="com1"/>
と
<csc output="myapp.exe" target="winexe" debug="true">
<sources>
...
</sources>
<references>
<include name="Interop.com1.dll"/>
...
</references>
</csc>
を、それがvar customer = new com1.Customer();
にエラーになります:私は次のNAntのを実行し、私のビルドスクリプトを実行し
public void DoStuff()
{
var customer = new com1.Customer();
customer.DoSomething();
}
次のスタックトレースを持つコード行:
System.Runtime.Serialization.SerializationException: The input stream is not a valid binary format. The starting contents (in bytes) are: 44-65-76-45-78-70-72-65-73-73-2E-58-74-72-61-45-64 ...
at System.Runtime.Serialization.Formatters.Binary.SerializationHeaderRecord.Read(__BinaryParser input)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadSerializationHeaderRecord()
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)
at System.ComponentModel.Design.DesigntimeLicenseContextSerializer.Deserialize(Stream o, String cryptoKey, RuntimeLicenseContext context)
at System.ComponentModel.Design.RuntimeLicenseContext.GetSavedLicenseKey(Type type, Assembly resourceAssembly)
at System.ComponentModel.LicenseManager.LicenseInteropHelper.GetCurrentContextInfo(Int32& fDesignTime, IntPtr& bstrKey, RuntimeTypeHandle rth)
at MyApp.MyClass.DoStuff()
私の質問は誰にも分かりますか?
+1スタイル。あなた自身の答えを受け入れるのをためらってはいけません。 – sehe