Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Diagram inside ElementHost gives exception (Read 3296 times)
basg
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Jan 21st, 2008
Diagram inside ElementHost gives exception
Jan 23rd, 2008 at 7:42pm
Print Post  
Hi,

I have been using the WPF diagram library succesfully so far within a full WPF environment. However, when I want to use it within an 'old' WinForms application I have to embed the WPF control inside an ElementHost. When I do this, I get an TypeInitializationException. I traced it back to the GraphicsUnit constructor, which makes use of the utilities class. When you execute this line in a windows forms (non-wpf) app, it will faill:

MindFusion.Diagramming.Wpf.GraphicsUnit pUnit = MindFusion.Diagramming.Wpf.GraphicsUnit.Pixel;

I guess there are some assumptions that are not valid outside a WPF environment.

Kind regards,

Bas


--
System.TypeInitializationException was unhandled
  Message="The type initializer for 'MindFusion.Diagramming.Wpf.GraphicsUnit' threw an exception."
  Source="MindFusion.Diagramming.Wpf"
  TypeName="MindFusion.Diagramming.Wpf.GraphicsUnit"
  StackTrace:
      at MindFusion.Diagramming.Wpf.GraphicsUnit..ctor(Double unitsPerInch, String name)
      at WindowsFormsApplication1.Form1.OnDoubleClick(EventArgs e) in C:\Developing\AgileDoc\trunk\software\AgileDoc\WindowsFormsApplication1\Form1.cs
:line 25
      at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
      at System.Windows.Forms.Control.WndProc(Message& m)
      at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
      at System.Windows.Forms.ContainerControl.WndProc(Message& m)
      at System.Windows.Forms.Form.WndProc(Message& m)
      at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
      at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
      at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
      at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
      at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNat
iveMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
      at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
      at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
      at System.Windows.Forms.Application.Run(Form mainForm)
      at WindowsFormsApplication1.Program.Main() in C:\Developing\AgileDoc\trunk\software\AgileDoc\WindowsFormsApplication1\Program.
cs:line 18
      at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
      at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
      at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
      at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
      at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
      at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.NullReferenceException
      Message="Object reference not set to an instance of an object."
      Source="MindFusion.Diagramming.Wpf"
      StackTrace:
           at MindFusion.Utilities.xe641d5636ba2c0e2()
           at MindFusion.Diagramming.Wpf.GraphicsUnit..cctor()
      InnerException:
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram inside ElementHost gives exception
Reply #1 - Jan 24th, 2008 at 10:58am
Print Post  
Hi,

That problem should be fixed in this version:
https://mindfusion.org/_beta/MindFusion.Diagramming.Wpf.zip

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
basg
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Jan 21st, 2008
Re: Diagram inside ElementHost gives exception
Reply #2 - Jan 24th, 2008 at 4:40pm
Print Post  
Yes, it seems to work now. Thanks for the quick response and fix!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint