14 Replies - 3261 Views - Last Post: 02 April 2012 - 01:51 PM Rate Topic: -----

#1 TheFreeman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 47
  • Joined: 31-December 11

Adding WPF Usercontrol to Window Form Error

Posted 02 April 2012 - 11:28 AM

Hey guys I don't know if any of you have came accross such an error but I cannot find a solution to it.

What is happening is every time I try to add a WPF user control to Windows Forms I keep getting an error.

Failed to create component .....

Has anyone every had this problem?

Thanks,
TheFreeman.
Is This A Good Question/Topic? 0
  • +

Replies To: Adding WPF Usercontrol to Window Form Error

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: Adding WPF Usercontrol to Window Form Error

Posted 02 April 2012 - 11:31 AM

do you have any code in the constructor of the user control?
Was This Post Helpful? 0
  • +
  • -

#3 TheFreeman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 47
  • Joined: 31-December 11

Re: Adding WPF Usercontrol to Window Form Error

Posted 02 April 2012 - 11:35 AM

Just InitializeComponent() ...
Was This Post Helpful? 0
  • +
  • -

#4 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: Adding WPF Usercontrol to Window Form Error

Posted 02 April 2012 - 11:36 AM

You also need to give us the FULL error message.
Was This Post Helpful? 0
  • +
  • -

#5 TheFreeman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 47
  • Joined: 31-December 11

Re: Adding WPF Usercontrol to Window Form Error

Posted 02 April 2012 - 11:37 AM

When I try to host it using the Host Element ... after I choose the WPF Usercontrol it gives another error saying make sure the Control has a Default Constructor.
Was This Post Helpful? 0
  • +
  • -

#6 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: Adding WPF Usercontrol to Window Form Error

Posted 02 April 2012 - 11:39 AM

Also, try doing a Clean build on the solution, then Rebuild the solution, then try again.

View PostTheFreeman, on 02 April 2012 - 02:37 PM, said:

When I try to host it using the Host Element ... after I choose the WPF Usercontrol it gives another error saying make sure the Control has a Default Constructor.


Give us the ACTUAL ERROR MESSAGES, not your interpretation of the error message. Every bit of the error message that you get from Visual Studio, you need to give to us, in it's entirety.
Was This Post Helpful? 0
  • +
  • -

#7 TheFreeman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 47
  • Joined: 31-December 11

Re: Adding WPF Usercontrol to Window Form Error

Posted 02 April 2012 - 11:39 AM

Yeah done that like 50 times already .... and still nothing..
Was This Post Helpful? 0
  • +
  • -

#8 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: Adding WPF Usercontrol to Window Form Error

Posted 02 April 2012 - 11:40 AM

Do you have a constructor that accepts no parameters? if not, create one.
Was This Post Helpful? 0
  • +
  • -

#9 TheFreeman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 47
  • Joined: 31-December 11

Re: Adding WPF Usercontrol to Window Form Error

Posted 02 April 2012 - 11:42 AM

yes off course I have a a method with the same name of the class without any parameters .. just to make things clear ... I also moved InitializeComponent() to loaded method
Was This Post Helpful? 0
  • +
  • -

#10 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: Adding WPF Usercontrol to Window Form Error

Posted 02 April 2012 - 12:02 PM

Quote

I also moved InitializeComponent() to loaded method


Why? That's not where it's suppose to be.

And it's will be hard to help you unless you post the ENTIRE error messages that you get.
Was This Post Helpful? 0
  • +
  • -

#11 TheFreeman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 47
  • Joined: 31-December 11

Re: Adding WPF Usercontrol to Window Form Error

Posted 02 April 2012 - 12:08 PM

I that just for testing I really dunno how to solve this .... Here is the error

This is the error I get in the Windows Form. I deleted the user control and the form and started back from scratch .... now I get this error ... If I do ignore and continue I will start getting the error I posted first.

The variable 'joyStickScreen1' is either undeclared or was never assigned.
Was This Post Helpful? 0
  • +
  • -

#12 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: Adding WPF Usercontrol to Window Form Error

Posted 02 April 2012 - 12:24 PM

Well there you go. You have a variable in the user control that is either undeclared or is never assigned a value. It tells you the variable name. Go check it out. Since you have posted absolutely no code, I can't tell you where to look.
Was This Post Helpful? 0
  • +
  • -

#13 TheFreeman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 47
  • Joined: 31-December 11

Re: Adding WPF Usercontrol to Window Form Error

Posted 02 April 2012 - 01:05 PM

JoyStick screen 1 is the name of the control in the Windows Form m8

             this.elementHost1 = new System.Windows.Forms.Integration.ElementHost();
            this.joyStickScreen1 = new FlightSimulation.Controler.JoyStickScreen();
            
            this.SuspendLayout();
            // 
            // elementHost1
            // 
            this.elementHost1.Location = new System.Drawing.Point(12, 12);
            this.elementHost1.Name = "elementHost1";
            this.elementHost1.Size = new System.Drawing.Size(315, 365);
            this.elementHost1.TabIndex = 0;
            this.elementHost1.Text = "elementHost1";
            this.elementHost1.Child = this.joyStickScreen1;
            // 
            // JoyStickDisplay
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(339, 389);
            this.Controls.Add(this.elementHost1);
            this.Name = "JoyStickDisplay";
            this.Text = "JoyStickDisplay";
            this.Load += new System.EventHandler(this.JoyStickDisplay_Load);
            this.ResumeLayout(false);



Was This Post Helpful? 0
  • +
  • -

#14 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: Adding WPF Usercontrol to Window Form Error

Posted 02 April 2012 - 01:11 PM

so joyStickScreen1 is the name of the WPF control that you are trying to add to the form?
Was This Post Helpful? 0
  • +
  • -

#15 TheFreeman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 47
  • Joined: 31-December 11

Re: Adding WPF Usercontrol to Window Form Error

Posted 02 April 2012 - 01:51 PM

I guess ye it is auto assigned to it when I drag and drop it in the Window Form
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1