Build Targeting Any CPU for WPF Element Host

Build Targeting Any CPU for WPF Element Host

Anonymous
Not applicable
683 Views
1 Reply
Message 1 of 2

Build Targeting Any CPU for WPF Element Host

Anonymous
Not applicable

What are the ramifications of building my add-in solution to target "Any CPU" versus "64 bit only"? 

 

I want to do this since the window's forms element host is unable to recognize my WPF user control. The element host object targets 32-bit assemblies. The screenshot below shows what happens when I choose UserControl1 from the element host dropdown when the assembly is built targeting 64 bit only.

 

I am able to add the user control and the add-in still loads into Navisworks when the solution is built targeting any cpu. 

image.png

 

0 Likes
Accepted solutions (1)
684 Views
1 Reply
Reply (1)
Message 2 of 2

awmcc90VZTT2
Contributor
Contributor
Accepted solution

This is actually a Visual Studio problem more than anything else. Some of the problems are unclear here so I'll just outline how the entire process should be done. 

 

1. You should move all your user controls to a separate project to be compiled into it's own dll and then your main project should reference them. Build the controls only project targeting Any CPU.

 

2. Visual Studio WPF designer is a 32 bit application (as far as I know up to VS2017) so it doesn't and can't recognize controls built for 64 bit. So when you want to work with the WPF designer have your solution target Any CPU and then when your done just build it for 64 bit. You won't be able to design when targeting 64 bit but who cares, the controls should still work fine when you actually are in the application.

0 Likes