West Wind .NET Tools and Demos
wwDotNetBridge: LoadAssembly fails
Gravatar is a globally recognized avatar based on your email address. wwDotNetBridge: LoadAssembly fails
  n/a
  All
  Aug 28, 2015 @ 07:21am
I'm getting the following error from wwDotNetBridge:

Could not load file or assembly 'file:///d:\jeffwork\wwdotnetbridge\testoib\bin\jefftestclass.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Here's my FoxPro Code:

do wwDotNetBridge
LOCAL loBridge as wwDotNetBridge
loBridge = CreateObject("wwDotNetBridge","V4")
? loBridge.LoadAssembly("bin\JeffTestClass.dll")

loOib = loBridge.CreateInstance("HelloWorld")
IF ISNULL(loOib)
? loBridge.cErrorMsg
RETURN
ENDIF

? loBridge.InvokeMethod(loOib,"Connect","")

*?loOib.Disconnect();

release loOib

return

Here's my C# code:

using System;
using System.Collections.Generic;
using System.Text;

namespace JeffTestClass
{
public class HelloWorld
{
public string Connect(string optionalWhatever)
{
return "HELLO WORLD";
}
}
}

I've got my C# project set to .NET Framework 4.0 and 32 bit.

Thanks...

Gravatar is a globally recognized avatar based on your email address. Re: wwDotNetBridge: LoadAssembly fails
  n/a
  Jeff L
  Aug 28, 2015 @ 08:42am
Nevermind...

Got it figured out. Had to exit VFP for some reason.

Gravatar is a globally recognized avatar based on your email address. Re: wwDotNetBridge: LoadAssembly fails
  Rick Strahl
  Jeff L
  Aug 28, 2015 @ 10:57am
Make sure you explicitly load the runtime you want to use at your application's startup. Just call

*** Load lib
DO wwDotnetBridge

*** create an instance to force the .NET runtime to load
*** with specified version

GetwwDotNetBridge("V4")

Only the first load laods the runtime, so if your app somewhere loads a V2 runtime, and then later wants to load V4 dll it won't work.

Always, always force the .NET runtime on startup to ensure you the version you expect to use which should be the highest that is required ("V4" is recommended).

+++ Rick ---


Nevermind...

Got it figured out. Had to exit VFP for some reason.


© 1996-2024