2012-03-10 1 views
11

프리즘 라이브러리와 함께 제공되는 System.Windows.Interactivity dll을로드하거나 해결하는 데 지속되는 문제가있는 C#/WPF 프리즘 (v4.0) 응용 프로그램이 있습니다. 나는이 문제를 디버깅/해결하려고 3 일 동안 계속 노력해왔다. 나는 .Net 어셈블리 해상도에 대해 많은 것을 배웠지 만 지금까지는 내 문제에 대해서는 행운이 없었기 때문에 필자는 필자의 도움을 간절히 구하는 StackOverflow 커뮤니티를 생각해 보았습니다. :)프리즘 어셈블리 참조 오류 : System.Windows.Interactivity

나는 행동을 추가하기 위해 System.Windows.Interactivity를 참조해야하는 더 큰 프리즘 응용 프로그램의 일부로 실행되는 모듈을 가지고 있습니다. 다음과 같이 따라서 나는 네임 스페이스를 지정하는 XAML 사용자 제어 할 수 있습니다 :

<UserControl x:Class="MyApp.Modules.SourcesModule.myView" 
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"> 

을 그리고 나서 다음과 같이 그 UserControl을의 하위 요소에 동작을 설정하려고 :

<ListBox Name="myListBox"> 
    <i:Interaction.Triggers> 
     <i:EventTrigger EventName="SelectionChanged"> 
      <i:InvokeCommandAction Command="{Binding SomeCommandOrOther}"/> 
     </i:EventTrigger> 
    </i:Interaction.Triggers> 
</ListBox> 

을 이상하게 프로젝트를 괜찮습니다. 연관 코드 숨김 파일과 을 입력 할 때 System.Windows.Interactivity 네임 스페이스의 개체에 대해 Intellisense 자동 완성을 얻을 수도 있습니다.

그러나 런타임에 이면 위의 ListBox 요소에서 XamlParseException이 발생합니다.

Could not load file or assembly 'System.Windows.Interactivity, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. 

의 InnerException 내가 조립 해상도에 대해 읽고 배운대로 형 System.IO.FileNotFoundException

"Could not load file or assembly 'System.Windows.Interactivity, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.":"System.Windows.Interactivity, PublicKeyToken=31bf3856ad364e35" 

...입니다, 일반적으로 강력한 이름의 어셈블리를 해결하는 문제가 제시 단순히 디스크에 dll을 찾을 수 없다는 것입니다 (예외 유형이 제안하는 것처럼).

=== Pre-bind state information === 
LOG: User = aricebo-array\me 
LOG: DisplayName = System.Windows.Interactivity, PublicKeyToken=31bf3856ad364e35 
(Partial) 
WRN: Partial binding information was supplied for an assembly: 
WRN: Assembly Name: System.Windows.Interactivity, PublicKeyToken=31bf3856ad364e35 | Domain ID: 1 
WRN: A partial bind occurs when only part of the assembly display name is provided. 
WRN: This might result in the binder loading an incorrect assembly. 
WRN: It is recommended to provide a fully specified textual identity for the assembly, 
WRN: that consists of the simple name, version, culture, and public key token. 
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue. 
LOG: Appbase = file:///C:/Users/me/Documents/Development Projects/Desktop apps/Prism/MyApp/Src/MyApp/bin/Debug/ 
LOG: Initial PrivatePath = NULL 
Calling assembly : PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35. 
=== 
LOG: This bind starts in default load context. 
LOG: No application configuration file found. 
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. 
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). 
LOG: Attempting download of new URL file:///C:/Users/me/Documents/Development Projects/Desktop apps/Prism/MyApp/Src/MyApp/bin/Debug/System.Windows.Interactivity.DLL. 
LOG: Attempting download of new URL file:///C:/Users/me/Documents/Development Projects/Desktop apps/Prism/MyApp/Src/MyApp/bin/Debug/System.Windows.Interactivity/System.Windows.Interactivity.DLL. 
LOG: Attempting download of new URL file:///C:/Users/me/Documents/Development Projects/Desktop apps/Prism/MyApp/Src/MyApp/bin/Debug/System.Windows.Interactivity.EXE. 
LOG: Attempting download of new URL file:///C:/Users/me/Documents/Development Projects/Desktop apps/Prism/MyApp/Src/MyApp/bin/Debug/System.Windows.Interactivity/System.Windows.Interactivity.EXE. 

흥미롭게도 나는 IL 디스어셈블러 (Ildasm.exe를)를 사용하여 내 건설 프로젝트, 시스템를 보면, : 문제의 조립 부분 바인딩에 대한 경고를 포함하여, 다음과 같이

퓨전 로그 정보는 .Windows.Interactivity는 참조 된 어셈블리 중 하나 인 매니페스트에 나열되어 있지 않지만 다른 참조 된 Prism dll은 정상적으로 표시됩니다. 예를 들어 : Referencing the correct System.Windows.Interactivity dll from Prism application :

.assembly extern Microsoft.Practices.Prism 
{ 
    .publickeytoken = (31 BF 38 56 AD 36 4E 35)       // 1.8V.6N5 
    .ver 4:0:0:0 
} 
.assembly extern Microsoft.Practices.Unity 
{ 
    .publickeytoken = (31 BF 38 56 AD 36 4E 35)       // 1.8V.6N5 
    .ver 2:0:414:0 
} 

이 문제는이 다른 StackOverflow의 질문에서 언급 한 것과 유사하다. 그러나 여기에 언급 된 사전 규정 된 해결책 (예 : 프리즘 버전의 System.Windows.Interactivity 사용)을 따르고 있습니다. 재미있게하기 위해 Expression Blend 3 및 4 SDK (물론 별도)와 함께 제공되는 System.Windows.Interactivity dll을 사용해 보았지만 그 중 하나도 사용하지 않았습니다.

프리즘 라이브러리와 함께 제공되는 다른 모든 DLL을로드 한 방법에 따라 System.Windows.Interactivity dll을로드하는 방법이 다르게 적용되지 않습니다. 이들은 모두/lib 폴더에 있습니다. 내 솔루션이고, Visual Studio 2010의 "참조 추가"> "찾아보기"메뉴를 사용하여 디스크에있는 모든 DLL을 가리켜 하나의 디렉토리에 모두 추가했습니다.)

다음으로 넘어갈 위치에 대한 모든 리드 가장 높이 평가 될 것입니다! 많은 감사합니다.

+0

GAC에 버전이 있습니까? 당신은 '모든 CPU'를 만들고 dev에서 64 비트를 참조하지만 런타임시 32 비트를 바인드합니까? FWIW, 나는 단서가 없다. –

+0

'gacutil -l'은 GAC에서 System.Windows.Interactivity의 버전이 없음을 확인합니다. 귀하의 질문에 대답하기 위해 프로젝트 속성의 플랫폼 대상으로 "모든 CPU"를 구축하고 있습니다. 테스트 머신/OS는 64 비트입니다. 그러나, 나는 런타임에 32 비트 바인딩에 대한 질문에 대답 할 수 있을지 모르겠다. 내가 어떻게 확인할지 말해 줄 수있어? 감사! –

+0

x86으로 구축하고 어떤 일이 발생하는지 확인하십시오. –

답변

32

마침내 대답을 찾았습니다!

프리즘 모듈의 DLL을 참조하면.NET 어셈블리 확인 메커니즘은 모듈의 bin 디렉토리가 아닌 호스트 응용 프로그램 (즉, 셸 및 부트 스트 래퍼가있는 응용 프로그램)의/bin 폴더에있는 참조 된 어셈블리를 찾습니다 (모듈을 별도로 설정했다고 가정) 내가 가진 것처럼 솔루션의 프로젝트).

우연히도 호스팅 응용 프로그램이 다른 모든 프리즘 DLL을 참조하기 때문에 우연히 모듈이이를 참조하면 호스팅 응용 프로그램의 bin 디렉토리에서 해당 응용 프로그램을 찾았습니다. 그러나 내 호스팅 응용 프로그램은 System.Windows.Interactivity를 참조하지 않았으므로 내 모듈에만 추가하면 호스팅 응용 프로그램/bin 디렉터리에서 찾을 수있는 DLL이 없습니다. DLL은 실제로 모듈의/bin 디렉토리에 복사되지만 어셈블리 해상도가 프리즘 응용 프로그램에서 작동하는 방식의 몇 가지 단점은 응용 프로그램이 해당 폴더의 어셈블리를 확인하지 않는다는 것을 의미합니다.

간단히 말해서 프리즘 응용 프로그램의 참조 된 어셈블리는 분명히 호스팅 응용 프로그램의/bin 폴더에 있어야합니다.

이 작업을보다 명확하고 지능적으로 만들기 위해 구성을 사용하는 방법을 살펴 보 겠지만 문제의 핵심은 적어도 발견되었습니다.

+0

[이 기사] (http://www.codeproject.com/Articles/165376/A-Prism-4-Application-Checklist)의 "응용 프로그램에 모듈 추가"절은 어셈블리 방법 관리에 대한 몇 가지 통찰력과 팁을 제공합니다 프리즘 앱 (즉, 모듈성의 단점)으로 함께 짜여져있다. –

+0

Expression Blend SDK의 dll을 사용하여 일반 Libs 폴더로 옮겼습니다. 내 모듈 중 하나는 쉘 응용 프로그램에 대한 참조 추가를 언급 한 것처럼 dll을 사용하고있었습니다. – mehul9595

+0

그것은 매력처럼 작동합니다! :) – StepUp