WPF and Windows Forms Mixed Environment Issue - c#

I have a WPF dll with a user control. It works just fine when I use it in a WPF project as a reference.
I needed to test in a mixed environment. So I created a Windows Forms solution, added the reference to both the WPF dll and the WindowsFormsIntegration dll. I placed an ElementHost in the form.
In the code behind, I called using on the WPF user control namespace, created an object of the user control and assigned it as the child of the ElementHost. Till this point, intellisense also seemed to work fine. The moment I built the project, however, I got a build error saying that the WPF namespace that I had used was not found.
All dlls are built in .NET 3.5 and the client solution is also in .NET 3.5. Is this a known issue? What could be off with this scenario?

Can you please follow the following link to check whether you have referred all the dll's which is necessary to run WPF custom control in Winform
http://msdn.microsoft.com/en-us/library/ms742215.aspx.

Related

Why can't I make a WinForms app register for COM interop?

I'm using Visual Studio 2015. I have successfully created a class library and selected:
Register form COM Interop
Make Assembly COM-visible
I've then managed to deploy this using a Setup Project to other users and it works great (although still don't understand why Intellisense doesn't work for it)
Now I'm trying to do the same for a WinForms application, but
Register form COM Interop
is not viable to apply, it's grayed out - should it be? And if so, why can't I register an application for COM Interop so I can manipulate it in other apps? (e.g. in Excel VBA)
The problem is that com registration normally makes only sense for assemblies (.dlls) and your WinForm application is normally a executable (.exe).
So I this case you should create a dll and move all the functions and classes that should be com visible into this assembly. Than make it Com visible and use it also from your executbale WinForms application.
To register a .NET assembly for COM Interop, the assembly has to be a class library, which is intended to be shared by applications.
A WinForms application, on the other hand, runs as a standalone program is not intended to be shared by other applications.
In this case, you can create a class library project, and creates a WinForms UserControl in the project, and expose the UserControl to other apps by making it COM visible.
Here is an old example, strangely it is hard to find more recent examples in my search.

Reference Universal Windows Library from WPF application

I am currently working on porting an existing wpf app to a universal windows app.
The existing application is fairly simple and is structured as a normal wpf project, containing the ui layer and filesystem interactions, and a class library containing the main application logic.
I was able to transfer the class library to a Universal Windows Library (windows 10 sdk) without making any substantial changes. This Universal Windows library exists in its own project inside the same solution as the original wpf application.
In order to minimize complexity, I would like both the upcoming Universal Windows app and the wpf app to reference the same library. However I am unable to add a reference to the universal Windows library from my wpf project. The library appears in the "add reference" dialog in visual studio, but after selecting the library and clicking OK, I am presented with a message saying that the reference could not be added.
Is what I am trying to do currently not possible, or is there something I'm missing? It seems foolish to need to save the same code into two different library projects for it to be usable.
You should be able to select the target frameworks of the class library by right clicking the project > Properties > Library and under targeting hit change, and select .Net framework X on your machine. Then, (aside from incompatible API's in your PCL) you'll be able to reference the project

USING windows control library in ASP.net

I created a control library by adding refrence to office interop excel to do some excel automation in client.The control works fine in windows forms Now i need to add the control in asp.net can somebody tell how to do that.
a windows class library will work just fine in asp.net. however, if you make a windows from control (or user control, etc) the control (etc.) will NOT work in asp.net.
all you have to do is add a reference to the assembly in your project. If your assembly references other assemblies, you will probably have to reference those in your project as well. As long as you do not attempt to create instances of controls that have a informs UI, you should be OK.
You cannot use Office Interop in an ASP.NET application, or any other server-based application. Please see Considerations for server-side Automation of Office, and please don't try it.

Hosting a WPF usercontrol in a Windows form

I have a WPF keyboard control that is hosted in a Windows form Control. It works fin on most computers, but not on all.
For some reason or another, on some computers when I open the win form with the wpf keyboard the wpf control is blank. Just get an empty square instead of the keyboard.
All of the parts of the project is in .net 3.0 and is built in C# 3.
Anybody have any ideas?
Update
I unfortunately don't have access to the computer my self only via a person on the other end of a phone.
I've even tried setting up a computer without .net 3.0. That gives me an error message
Tried .net 3.0 without any service pack also, but it doesn't recreate the problem.
Did you ensure that you have the right version of .NET installed on the computers in which they are not working ?

System.Windows.Shell Reference missing

I have a windows form application and i want to make my own custom jumplist. To do this i need to use the namespace System.Windows.Shell but i can't access it, and i can't find a reference for it in the list of references either. I have checked some tutorials but they all use XAML (WPF Application) and some of them just mentions this can be done by coding as well.
So my question is, is it possible to access the namespace needed in a windows form app or do i need to use WPF? And if it is possible then how? And if not, then is there another way to do it in a windows form app?
I'm using Visual Studio 2010 Ultimate (C#).
Thanks in advance!
The System.Windows.Shell namespace is in the PresentationFramework.dll assembly. You can find that out on your own if you search for the namespace, the containing assembly will be displayed in the details.
An assembly reference to PresentationFramework is required. The namespace is only available in .NET 4. Use Project + Properties, verify the Target Framework setting. Using it in a Winforms app is fine, the classes don't require the WPF plumbing to work. They are wrappers for the Vista API extensions.

Categories