How to force WindowsFormsIntegration to be loaded?

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,
 
N

not_a_commie

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.
 
N

not_a_commie

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.
 
H

Haiping

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.
 
H

Haiping

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.
 
N

not_a_commie

That hard-coded path will give you portability issues. Is the file
available in your GAC?
 
N

not_a_commie

That hard-coded path will give you portability issues. Is the file
available in your GAC?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top