본문 바로가기
C++ 200제/코딩 IT 정보

C# ArcGIS 오류 : 프로그램을 잘못된 형식으로 로드하려고 했습니다.

by vicddory 2017. 12. 25.

C# ArcGIS 오류 : 프로그램을 잘못된 형식으로 로드하려고 했습니다.


ArcGIS 에러 메시지


"(ArcGIS)..... 또는 여기에 종속되어 있는 파일이나 어셈블리 중 하나를 로드 할 수 없습니다. 프로그램을 잘못된 형식으로 로드하려고 했습니다."


ArcGIS 오류 에러 ESRI[C# ArcGIS 오류 : 프로그램을 잘못된 형식으로 로드하려고 했습니다]


위 에러는 ArcGIS를 32비트에서 만든 뒤, 64비트에서 실행할 때 발생하는 ArcGIS 에러입니다. 기본적으로 ArcGIS는 윈도우XP에서 동작하는 프로젝트가 윈도우7에서도 구동되도록 서비스팩을 제공하지만, 완벽하게 호환되진 않습니다.


그래서 ArcGIS에 별도의 사용자 작업이 필요합니다. 솔루션은 아래 링크를 따라가면 되고, ESRI에서 제공하고 있습니다.


- 요약 - 


1. 프로젝트 우클릭 – 프로젝트 언로드(L) 클릭

2. 프로젝트 우측의 괄호 안에 "사용할 수 없음"을 확인한 뒤, 프로젝트 우클릭 – 편집 ….csproj 클릭

3. 새 창에서 맨 뒤의 </Project> 종료 태그 앞줄에 아래 코드 삽입


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!--
      Workaround for VS2010 .NET 3.5 application referencing x86 assembly in resx file on 64-bit OS
      http://social.msdn.microsoft.com/Forums/en-US/msbuild/thread/e5900710-9849-4d10-aa28-48b734d06bf2       
-->
 
<PropertyGroup>
  <ForceResGen32Bit Condition="'$(MSBuildToolsVersion)'=='4.0' And '$(PROCESSOR_ARCHITEW6432)'!='' And '$(TargetingClr2Framework)'=='true' And '$(PlatformTarget)'=='x86'">true</ForceResGen32Bit>
</PropertyGroup>
<Target Name="BeforeResGen" Condition="'$(ForceResGen32Bit)' == 'true'">
  <PropertyGroup>
    <ResGenSdkToolsPath>$(IntermediateOutputPath)ResGenForced32Bit\</ResGenSdkToolsPath>
  </PropertyGroup>
  <!-- Copy resgen.exe to intermediate working directory for UAC settings -->
  <Copy SourceFiles="$(TargetFrameworkSDKToolsDirectory)ResGen.exe" 
        DestinationFiles="$(ResGenSdkToolsPath)ResGen.exe" />
  <!-- corflags.exe resgen.exe /32BIT+ /Force-->
  <Exec WorkingDirectory="$(ResGenSdkToolsPath)" 
        Command=""$(TargetFrameworkSDKToolsDirectory)corflags.exe" ResGen.exe /32BIT+ /Force" />
  <!-- GenerateResource Task parameters
        Using the non-64bit Tracker.exe and indicate resgen.exe has been forced to x86 -->
  <PropertyGroup>
    <ResGenTrackerSdkPath>$(SDK40ToolsPath)</ResGenTrackerSdkPath>
    <ResGenToolArchitecture>Managed32Bit</ResGenToolArchitecture>  <CacheTargetFrameworkSDKToolsDirectory>$(TargetFrameworkSDKToolsDirectory)</CacheTargetFrameworkSDKToolsDirectory>
    <TargetFrameworkSDKToolsDirectory>$(ResGenSdkToolsPath)</TargetFrameworkSDKToolsDirectory>
  </PropertyGroup>
</Target>
<Target Name="AfterResGen" Condition="'$(ForceResGen32Bit)' == 'true'">
  <PropertyGroup>
<TargetFrameworkSDKToolsDirectory>$(CacheTargetFrameworkSDKToolsDirectory)</TargetFrameworkSDKToolsDirectory>
  </PropertyGroup>
  <RemoveDir Directories="$(ResGenSdkToolsPath)" Condition="Exists('$(ResGenSdkToolsPath)')" />
</Target>
cs


ArcGIS 프로그램을 잘못된 형식으로 로드하려고 했습니다[C# ArcGIS 오류 : 프로그램을 잘못된 형식으로 로드하려고 했습니다]


4. 소스를 삽입한 뒤 저장한 다음, 프로젝트 우클릭 – 프로젝트 다시 로드(L) 클릭

5. 그 뒤, ArcGIS 프로젝트를 다시 빌드하면 프로그램이 정상적으로 구동되는 것을 확인


-- 요약 끝 --


ArcGIS 서비스팩이 계속해서 업데이트되곤 있지만, 10.0 미만의 버전은 윈도우7에서 아예 설치조차 되지 않는 등, 문제점은 많이 존재합니다. 다행히 ESRI에서 상황에 맞는 솔루션은 제공하고 있는데, 썩 만족스럽거나 완벽하진 않습니다.


C# ArcGIS 오류 : 프로그램을 잘못된 형식으로 로드하려고 했습니다.

댓글