04-26-2013 06:29 AM
Hi,
I'm using Measurement Studio 2012 with Visual Studio 2010 for the development of a .NET 4.0 WinForms application in C#.
My application contains a WaveFormGraph control and some other UI controls of Measurement Studio.
Everything works fine on a machine where Measurement Studio is installed.
But when I try to deploy my application to another computer (via setup project) an exception error will occur immediately after starting the application.
The exception indicates that the assembly "NationalInstruments.Common, Version=12.0.40.253, Culture=neutral, PublicKeyToken=dc6ad606294fc298" is not found.
Stack trace:
GraphForm.InitializeComponent()
GraphForm..ctor()
...
Program.Main()
Actually, there is version 12.0.40.258 of the NationalInstruments.Common assembly referenced in my Visual Studio project and I can not even find the older version 12.0.40.253 on my hard disk.
I also analyzed my executable with a .NET Reflector and found out that there are two different versions of NationalInstruments.Common assembly referenced in it. I checked every setting in Visual Studio and I have no idea where the additional version 12.0.40.253 comes from.
Then I tried a workaround by adding a binding redirection to app.config:
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="NationalInstruments.Common" publicKeyToken="dc6ad606294fc298"
culture="neutral" />
<bindingRedirect oldVersion="12.0.40.100-12.0.40.257"
newVersion="12.0.40.258" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
This took me one step forward but led me to another exception error caused by type initialization of NationalInstruments.UI.Internal.WaveformPlotElement.
Stack Trace:
NationalInstruments.UI.Internal.WaveformPlotElement..ctor(ControlElement parent, Object obj)
NationalInstruments.UI.WaveformPlot.CreateElement()
NationalInstruments.UI.ControlEntity..ctor()
NationalInstruments.UI.Plot..ctor()
NationalInstruments.UI.XYPlot..ctor()
NationalInstruments.UI.WaveformPlot..ctor()
GraphForm.InitializeComponent()
GraphForm..ctor()
...
Program.Main()
Has anyone an idea what the problem is and how I get my application working on another machine?
Why are there two different versions of one assembly referenced in my application?
Kind regards,
Tom*S
04-29-2013 05:00 AM
Use policy files to ensure compatibility between different versions. This is also used by NI itself.
Hope it helps
Christian
04-29-2013 05:07 AM
If this is .net 4 related you should try to use
<?xml version ="1.0"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0.30319"/>
</startup>
</configuration>
Christian
04-29-2013 06:32 AM
Hi Christian,
Thank you for your response!
There are already some policy files of National Instruments in the application folder which were created by the setup.
Amongst others there are the files:
policy.9.0.NationalInstruments.Common.dll
policy.9.1.NationalInstruments.Common.dll
policy.12.0.NationalInstruments.Common.dll
And there's a file named NationalInstruments.Common.config with the following content:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="NationalInstruments.Common" publicKeyToken="dc6ad606294fc298"
culture="neutral" />
<bindingRedirect oldVersion="7.0.0.275-7.1.40.999"
newVersion="12.0.40.258" />
<bindingRedirect oldVersion="8.0.40.100-8.0.40.999"
newVersion="12.0.40.258" />
<bindingRedirect oldVersion="8.1.40.100-8.1.40.999"
newVersion="12.0.40.258" />
<bindingRedirect oldVersion="8.5.40.100-8.5.40.999"
newVersion="12.0.40.258" />
<bindingRedirect oldVersion="8.6.40.100-8.6.40.999"
newVersion="12.0.40.258" />
<bindingRedirect oldVersion="8.7.40.100-8.7.40.999"
newVersion="12.0.40.258" />
<bindingRedirect oldVersion="8.9.40.100-8.9.40.999"
newVersion="12.0.40.258" />
<bindingRedirect oldVersion="9.0.40.100-9.0.40.999"
newVersion="12.0.40.258" />
<bindingRedirect oldVersion="9.1.40.100-9.1.40.999"
newVersion="12.0.40.258" />
<bindingRedirect oldVersion="12.0.40.100-12.0.40.257"
newVersion="12.0.40.258" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
And despite of these files my application is still looking for the additionally referenced assembly version 12.0.40.253.
Without the binding redirection in app.config my application aborts on startup with the exception error indicating this missing assembly version.
I also tried your second suggestion but that doesn't seem to fix the problem.
04-29-2013 06:51 AM
Try to use the fresh released MeasStudio V2013 then
05-06-2013 04:21 AM
The list of bugfixes of the new Measurement Studio 2013 is very short and my issue is not listed there:
http://www.ni.com/white-paper/14476/en
So, I think updating to version 2013 will not solve my problem.
But I'm already in contact with the NI support. I hope they can locate the problem and will provide a solution.
05-30-2013 09:14 AM
Was this issue ever resolved? I have the same exact issue where I've just upgraded to 12.0.40.258 but it wants 12.0.40.253 and I cannot find a reference to this anywhere in any of the projects.
05-31-2013 02:24 AM
05-31-2013 03:05 AM
No, this issue has not been resolved, yet. I was in contact with NI but they couldn't re-produce the problem. And currently, I have no time to do further research work on that issue. I will continue later and if I find a solution I will post it here.
08-29-2017 08:17 AM
I know I'm late but for others who may stumble across the same problem,
this helped me out, at least for the NationalInstrumments.Common assembly versioning problem: