0

I am getting this exception,

System.IO.FileLoadException: A procedure imported by 'GeometryUtils.dll' could not be loaded

while trying to call Activator.CreateInstanceFrom(geomUtilsAssemblyPath, "GeometryUtils.IsmRegionFactory");

I can see GeometryUtils.dll gets loaded using process explorer along with its dependencies. Dependency Walker and Reflector does not report any issue as well.

FYI, GeometryUtils is built using .NET 4.0 and calling process is built using .NET 2.0. So I have specified,

<startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>

in executeable config file.

Any ideas, what may be going on?

J. Steen
  • 15,470
  • 15
  • 56
  • 63
Usman Khan
  • 139
  • 2
  • 12
  • 1
    You can't call .NET 4 assembly from a .NET 2 process. The other way around works. – leppie Feb 07 '13 at 11:30
  • This code worked perfectly fine i.e. .NET 2 processed loaded .NET 4 assembly with LegacyV2Runtime tag. Something got changed lately that I am unable to figure it out. – Usman Khan Feb 07 '13 at 11:40
  • You will have to change target framework of the dll and rebuild the solution.as @leppie you can not call a 4.0 assembly from a 2.0 net assembly. – NetStarter Feb 07 '13 at 11:40
  • Guys, if .NET 2.0 process .NET 4.0 is not possible then what does this tag do, – Usman Khan Feb 07 '13 at 12:07
  • http://stackoverflow.com/questions/1604663/what-does-uselegacyv2runtimeactivationpolicy-do-in-the-net-4-config – default Feb 07 '13 at 12:30

1 Answers1

4

A 2.0 process can't support a 4.0 class library.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445