Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

TypeInitalizationException: The type initializer for 'NationalInstruments.UI.Internal.WaveformPlotElement' threw an exception.

I am currently have a probelm with using WaveformPlots. When ever I try to use a "new NationalInstruments.UI.WaveformPlot();" I get this exception. I am using Visual Studios 2010 and .NET 4. I guess is it is related to using a the .NET 4 framework, but the funny thing is I have able to get a WaveformPlot to work using WPF with a WindowsFormsHost w/ .NET4 and the Control worked fine. But When I tried to use the same control in a Forms Application it gets this error. Any Solutions??

 

Exception Details:

 

System.TypeInitializationException was unhandled
  Message=The type initializer for 'NationalInstruments.UI.Internal.WaveformPlotElement' threw an exception.
  Source=NationalInstruments.UI
  TypeName=NationalInstruments.UI.Internal.WaveformPlotElement
  StackTrace:
       at NationalInstruments.UI.Internal.WaveformPlotElement..ctor(Object obj)
       at NationalInstruments.UI.WaveformPlot.CreateElement()
       at NationalInstruments.UI.ControlEntity..ctor()
       at NationalInstruments.UI.Plot..ctor()
       at NationalInstruments.UI.CartesianPlot..ctor()
       at NationalInstruments.UI.XYPlot..ctor()
       at NationalInstruments.UI.WaveformPlot..ctor()
       at AnalysitAutomation.Form1.InitializeComponent() in C:\Users\Michael\Desktop\New folder (2)\AnalysitAutomation2010\AnalysitAutomation\Form1.Designer.cs:line 41
       at AnalysitAutomation.Form1..ctor() in C:\Users\Michael\Desktop\New folder (2)\AnalysitAutomation2010\AnalysitAutomation\Form1.cs:line 291
       at AnalysitAutomation.Program.Main() in C:\Users\Michael\Desktop\New folder (2)\AnalysitAutomation2010\AnalysitAutomation\Program.cs:line 18
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
       at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
       at System.Activator.CreateInstance(ActivationContext activationContext)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.IO.FileLoadException
       Message=Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.
       Source=NationalInstruments.Common
       StackTrace:
            at NationalInstruments.PrecisionTimeSpan.FromSeconds(Double value)
            at NationalInstruments.UI.Internal.WaveformPlotElement..cctor()
       InnerException:

 

Thanks.

0 Kudos
Message 1 of 4
(4,416 Views)

Hello -

 

Have you seen KB 58D8K1XU?  I think you are running into known limitation number 2 - at the bottom of the document.  Take a look and let me know if that does not resolve it for you.

 

Thanks -

 

NickB

National Instruments

0 Kudos
Message 2 of 4
(4,414 Views)

Ok, so that post meantions this:

 

If your application depends on any National Instruments mixed-mode assemblies such as NationalInstruments.Common.Native, you must create a config file for your application similar to the one in the Attachments section. Specifically, you must specify useLegacyV2RuntimeActivationPolicy="true" for the startup tag. If you fail to create this config file, you will receive the error "Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information. ".

 

I can create the configuration file, but how do I add this information to the configuration file?

Thanks.

0 Kudos
Message 3 of 4
(4,382 Views)

Sorry - I'll make sure that text gets updated to be more specific. 

 

Essentially, you just need to download the config file attached at the bottom of the document, change "app" to be the name of your executable (your_app_name_here.exe.config), and then place the config file directly next to your application.

 

NickB

National Instruments

0 Kudos
Message 4 of 4
(4,378 Views)