02-02-2024 10:25 AM
Dear all,
(If this question is raised in the wrong group, I do apologize)
We've been using TS2012 for quite some time (well since 2012) and during this time we've (long before I arrived at the scene) written C# drivers using Visual Studio and .Net Framework 4.6 for interfacing with our instruments and other devices that we have.
We've been using the Ivi.ConfigServer.Interop to get the IVI settings configured using NiMax and (I presume) the IVI Compliance package. This has worked well using the 32-bit version.
Now, I'm in the process of recompiling our entire suite of supporting applications and drivers to use 64-bit TestStand 2023.
Our (today 32-bit) drivers can be registered today using the following code (snippet)
private static void Register(string pathToAssembly)
{
IviConfigStore configStore = new IviConfigStoreClass();
configStore.Deserialize(configStore.MasterLocation);
try
{
configStore.SoftwareModules.Remove(versionIndependentProgID);
}
catch
{
}
IviSoftwareModule sm = new IviSoftwareModuleClass
{
Name = versionIndependentProgID,
Description = $"Driver for {versionIndependentProgID}",
ProgID = progId
};
IviStructure st = new IviStructureClass
{
Name = "Configurable Initial Settings"
};
IIviInteger specificSetting = new IviInteger
{
Name = "SpecialSetting",
Description = "This setting sets somthing extra",
ReadOnly = false,
Value = 123,
UsedInSession = "Required"
};
st.DataComponents.Add(specificSetting);
sm.DataComponents.Add(st);
sm.ModulePath = pathToAssembly;
configStore.SoftwareModules.Add(sm);
configStore.Serialize(configStore.MasterLocation);
}
The reference used to access the IVI config store is
C:\Program Files\IVI Foundation\IVI\Bin\Primary Interop Assemblies\Ivi.ConfigServer.Interop.dll
which is Version=1.6.0.0, PublicKeyToken=a128c98f1d7717c1
After this a driver shows up nicely in NiMax under a IVI drivers and can be tied to a driver session and then to a logical name.
However the problem begins when trying to register the driver as a x64 (64-bit driver).
Looking at the specification
I understand it as version 1.6.0.0 should include support for x86 and x64 drivers.
However, when running the code above, it works nicely for a 32-bit driver in a 32-bit context, but when running it in a x64 bit context with a compiled x64 bit driver it fails.
The failure occurs on the line
sm.ModulePath = pathToAssembly;
where the exception "Exception from HRESULT: 0x80041222" is thrown, which seem to mean "The operation is not supported. "
I've tried to locate newer versions of the Ivi.ConfigServer.Interop.dll, but version 1.6.0.0 is all I can find.
I've run the NI Package Manager 2023 and made sure that I've upgraded the IVI Compliance Package to 2024 Q1 but that does not seem to help either. I'm still stuck at version 1.6.0.0. Trust me when I say I've checked my entire drive if a newer version was put somewhere else.
Can someone give me some advice what I'm doing wrong here? Any help would be greatly appreciated.
The specification above says that version 1.6 should support ModulePath64 as well as ModulePath32 for version 1.6.0.0 but that does not seem to be true.
King regards
Magnus
Solved! Go to Solution.
02-02-2024 10:43 AM
Argh....
I think I found the answer myself....
In the code below, the interface IIviSoftwareModule2 should be used instead.
Something like this pseudo code
var sm = new IviSoftwareModuleClass
{
Name = versionIndependentProgID,
Description = $"Driver for {versionIndependentProgID}",
ProgID = progId
};
var softwareModule = sm as IIviSoftwareModule2;
.....
softwareModule.ModulePath64 = pathToAssembly;
....
configStore.SoftwareModules.Add(softwareModule as IviSoftwareModule);
Then it seems to work !!
Sorry for bothering anyone.
King regards
Magnus