일부 C# 코드에서 참조하는 COM 어셈블리 (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