How to force WindowsFormsIntegration to be loaded?

  • Thread starter Thread starter Haiping
  • Start date Start date
H

Haiping

Hello,

I understand that WindowsFormsIntegration is loaded on demand. Is there a
way to force WindowsFormsIntegration to be loaded?

I have some UserControls with some WindowsFormsHosts. If I call XamlWriter
first to save them and then call XamlReader to read them there is no problem.
But if I call XamlReader first to read the saved UserControl I got following
error message:

The tag"WindowsFormsHost" does not exist in XML namesapce
"clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration".

I think WindowsFormsIntegration was loaded by XamlWriter but XamlReader does
not load WindowsFormsIntegration. How to force WindowsFormsIntegration to be
loaded without call XamlWriter?

Thanks for any help,
 
Try Assembly.Load or AppDomain.Current.Load. Also, you could try
putting in the assembly.FillName in your xmlns declaration instead of
just the shortened assembly name.
 
Try Assembly.Load or AppDomain.Current.Load. Also, you could try
putting in the assembly.FillName in your xmlns declaration instead of
just the shortened assembly name.
 
Thank you not_a_commie:).

The following line works for me:

Assembly.LoadFrom(@"C:\Program Files\Reference
Assemblies\Microsoft\Framework\v3.0\WindowsFormsIntegration.dll");

I also tryed Assembly.Load() and AppDomain.CurrentDomain.Load(). They throw
exceptions.
 
Thank you not_a_commie:).

The following line works for me:

Assembly.LoadFrom(@"C:\Program Files\Reference
Assemblies\Microsoft\Framework\v3.0\WindowsFormsIntegration.dll");

I also tryed Assembly.Load() and AppDomain.CurrentDomain.Load(). They throw
exceptions.
 
That hard-coded path will give you portability issues. Is the file
available in your GAC?
 
That hard-coded path will give you portability issues. Is the file
available in your GAC?
 
Back
Top