Could not load file or assembly 'VOWin32APILibrary

This forum is meant for questions and discussions about the X# language and tools
Post Reply
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Could not load file or assembly 'VOWin32APILibrary

Post by ic2 »

We still have a start problem with the converted VO->X# solution. Directly, even before hitting the first line of the function Start, we get the following exception:

FileLoadException: Could not load file or assembly 'VOWin32APILibrary, Version=2.1.0.0, Culture=neutral, PublicKeyToken=a967d8055360a7b9' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)


What we did is:

1 We've updated X# to 2.10. with the GAC option unchecked To be 100% sure, all references where removed and reapplied to the DLL's from the Assemblies directory.
2 We've copied these 2.10 DLL's from Assemblies to 2 locations:
- the directory found with System.IO.Directory.GetCurrentDirectory() = "C:FranksourcereposKleijnXSDebug
- the directory found in the error
StackTrace:
at $AppInit()
at Kleijn.Exe.Functions.Start() in C:FranksourcereposKleijnXSKleijnStart.prg:line 1588

Not sure why these 2 differ...

But while all locations have the latest DLL=the DLL found in the properties, it still gives this error.

Why?

Dick/Frank
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Could not load file or assembly 'VOWin32APILibrary

Post by robert »

Dick / Frank,

The WIn32APILibrary needs to be used in X86 mode. This library (which is converted from VO) freely mixes 32 bit Integers with Pointers. In 64 bits mode the pointers would be 64 bits.
I suspect that your main program / assembly is compiled in AnyCPU.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Could not load file or assembly 'VOWin32APILibrary

Post by ic2 »

Hello Robert,

We changed from AnyCPU to X86 and the only change is that compiling now takes twice as long but the exception and >8000 warnings remain.

If I look in the error:

System.Exception
HResult=0x80131500
Message=Error when executing code in INIT procedure(s)
Source=Kleijn
StackTrace:
at $AppInit()
at Kleijn.Exe.Functions.Start() in C:FranksourcereposKleijnXSKleijnStart.prg:line 1588

Inner Exception 1:
FileLoadException: Could not load file or assembly 'VOWin32APILibrary, Version=2.1.0.0,

why does it say Version=2.1.0.0? As the .DLL itself is 2.10.0.3.

I think that is where it goes wrong, but how & why?

Dick/Frank
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Could not load file or assembly 'VOWin32APILibrary

Post by robert »

Dick/ Frank,
I think you have included a reference to an assembly (one of your own maybe?) that was compiled with an earlier version of X#.
One of the 8000 warnings will probably be about that.
I need to see the project to determine which assembly is causing the problems..

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Could not load file or assembly 'VOWin32APILibrary

Post by ic2 »

Hello Robert,
robert wrote: I think you have included a reference to an assembly (one of your own maybe?) that was compiled with an earlier version of X#.
One of the 8000 warnings will probably be about that.
Indeed, and thanks for your, again, super fast reaction!

Eventually we opened the exe as created in ILSpy and went through every dependency, opening them to see which X# DLL versions were used, and the culprit was bBrowser where it showed 2.1.0.0. Not sure if there's a faster way, browsing through 8000 warnings is not really fast either.

We repaired the error and included the newly created DLL's and now the program starts. No doubt still a lot to solve, but this is a good start.

I have 1 question left. Why do Explorer properties, details state 2.10.0.3 as file version and Properties in VS of the referenced X# DLL's, pointing to the same location, state 2.6.0.0. as Version number?

Dick
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Could not load file or assembly 'VOWin32APILibrary

Post by robert »

Dick,

2.6.0.0 is the assembly version
2.10.0.3 is the file version.

We have kept the assembly version "stable" since 2.6. This means that every new (file) version is binary compatible with the previous version. We can't change method prototypes or property prototypes. We can add fields, method (overloads) and properties. That requires extra work on our side. But this also makes sure that if you have a 3rd party product that is created against an earlier X# version will still work.

In your case bBrowser was compiled against a MUCH older version and therefore the error occurs.
Microsoft has done something similar: even if you have .Net framework 4.8 on your machine, mscorlib.dll is still version 4.0.
On my machine the File Version of mscorlib.dll is 4.8.4470.0.

When you develop an app against for example Framework 4.7.2 then the compiler is not directly referencing the mscorlib.dll in the registry but it uses a so called "reference assembly". This is an "empty" assembly that contains all the public and protected members of the classes that existed in .Net framework 4.7.2. This prevents you from accidentally using code that is not supported on that framework version but only on a later version.
When you run your app then the mscorlib.dll from the GAC is used which also has assembly version 4.0 but file version 4.8.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
ic2
Posts: 1798
Joined: Sun Feb 28, 2016 11:30 pm
Location: Holland

Could not load file or assembly 'VOWin32APILibrary

Post by ic2 »

Hello Robert,

Thanks for the informative explanation!

As written in the bBrowser post https://www.xsharp.eu/forum/public-prod ... -and-error: how could it go wrong with the DLL's included with our bBrowser order of just a few months ago, while Wolfgang states that he is still using the 1 year old DLL's with the latest X#?

Dick
Post Reply