2011-07-06 1 views
1

일부 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() 

내 질문은 누구나 아는 이유는 무엇입니까?

답변

2

나는 이것을 알아 냈다. 응용 프로그램은 <project>\Properties\Licenses.licx 파일을 가지고 있습니다. NAnt에서 응용 프로그램을 빌드 할 때 우리는 해당 파일을 <csc><resources/></csc> 블록에 포함 시켰습니다. 어떤 이유로 나는 interop 참조를 추가 할 때까지이 작업을했습니다.

내가해야 할 일은 NAnt <license/> 작업을 사용하여 licx에서 라이센스 파일을 만드는 것입니다. 해당 작업의 출력이 <project>\Properties\LIcenses.licx 파일을 빌드 스크립트의 <csc><resources/></csc> 부분으로 대체했습니다.

그리고 그걸로 Bob은 정말로 내 삼촌이었습니다.

+0

+1 스타일. 자신의 대답을 받아들이는 것을 망설이지 말라. – sehe

관련 문제