.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

hosting a WPF control library in a WF application

Posted By:      Posted Date: September 24, 2010    Points: 0   Category :WPF

When I try to integrate a WPF control library in a WF code activity object I get the exception "The calling thread must be STA, because many UI components require this."  Here is a snippet:


private void OpenGUI()


           //Load GUI

           mainGUI = new WPFControlLibrary.UserControl_GUI();



When the mainGUI = line is executed, I get the error.

Please excuse my ignorance, I am a novice in WF and WPF.


Thanks in advance for any help.

View Complete Post

More Related Resource Links

Problem hosting a WPF user control in a windows form application

I have a windows forms application and want to to use WPF inside this application. So I have add a WPF user control into my project. Then I take a ElementHost from the toolbox and put it on my windows forms. The problem is now, when I want to add the WPF control with "Edit Host Content" I get the message "This ElementHost is currently not hosting any editable content....." What's wrong? How can I embed my implemented WPF control into the ElementHost ?

Localization not working in class library (composite control)



I have a class library called WEM.portal which used Resource files to localise text in my composite controls.

I store my resource files (eg MyResourceFile1.resx) in App_GlobalResources folder and then refer to them using

MyLabel1.text = My.Resources.MyResourceFile1.MyResourceKey1

This is all working ok until I create seperate files for each language such as MyResourceFile1.FR-fr.resx.

I have implemented this throughout my other web applications but the Class Library doesnt seem to want to work the same way

When I load the page it correctly showes the resourced keys which I have done through the web application BUT the resource keys in the composite controls does not seem to pick up the culture code.

Am I missing something stupid. Ive tried

  • changing the Build Action on the resource file to Content and Custom tool to GlobalResourceProxyGenerator
  • Creating a resourceManager but to no avail


Convert WCF service to self hosting application


 I created project as a  WCF Service application and now according to recuriment that needs to be converted as a self hosting application

How can i do this?

Converting WCF service app to Self hosting app?

Enterprise Library: Take Exception To Critical Errors With Custom Application Blocks


Enterprise Library is a collection of application functionality blocks that you can re-use in your application for common functionality you'd otherwise have to write again and again. Here Jay Hilyard explains how to use them.

Jay Hilyard

MSDN Magazine September 2006

Data Points: The Enterprise Library Data Access Application Block, Part 3


E nterprise applications can have a wide variety of data update requirements. Sometimes you need to save multiple rows of changes at once within a single transaction. Other times, the user must be allowed to enter multiple rows of data, send them to the database in a batch; and if a row or two fails, only the rows that succeeded should be committed and remain committed.

John Papa

MSDN Magazine October 2005

Data Points: The Enterprise Library Data Access Application Block, Part 2


Last month I explored the foundation of the Enterprise Library Data Access Application Block (DAAB) including how it all fits into an architecture (see Data Points: The Enterprise Library Data Access Application Block, Part 1).

John Papa

MSDN Magazine August 2005

Data Points: The Enterprise Library Data Access Application Block, Part 1


A solid data access later (DAL) can benefit an application by hiding redundant tasks, helping handle exceptions more gracefully, helping clean up resources more efficiently, and providing a layer of abstraction from the database.

John Papa

MSDN Magazine July 2005

Reg File Upload control to upload files from document library


In Field Upload control if we click browse button it allow us to search file in our hard disk but now as per my requirement as soon as user clicks ‘Browse’ button it should point to the document libraries and their files in site.Let me know how could i achieve this?

Thanks & Regards,


Where is the Visual Studio 2008 Web Control Library Template


Does a project exist for grouping user controls? Visual Studio 2005 had this template but it does not appear to exist in 2008.

We will be creating several User Controls and would like them grouped accordingly.


Thanks in advance for any responses.

Binding byte[] to image control in navigation application leaks

Hi there, I have a (minimal) navigation application with two pages. Page1 contains an image. Switching between pages is done via a buttonhandler in code behind, for instance, (this.NavigationService.Navigate(new Page2())) The image is loaded in code behind via: private void LoadImage() { string fileName = "./images/image.bmp"; if (!new FileInfo(fileName).Exists) throw new Exception("File name doesn't exist"); using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { this.ImageData2 = new byte[fs.Length]; fs.Read(this.ImageData2, 0, System.Convert.ToInt32(fs.Length)); fs.Close(); } } ImageData2 is a byte[] property that sends a propertychange event on changing. ImageData2 is bound to an image in xaml: <Image Grid.Row="1" Source="{Binding Path=ImageData2, Mode=OneTime}"/> When we unload Page1 the following clean up code is executed private void Page_Unloaded(object sender, RoutedEventArgs e) { this.ImageData2 = null; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); } Now, when I start changing pages, I expect the Page we leave to unload, so the GC removes the byte array. However, it doesn't. Am I missing something? Binding the image to a BitmapImage (ImageData1, as you might have guessed:-) ) doesn't leak.

Using MVVM with new Ribbon Control Library

Hi, As new ribbon for wpf http://www.microsoft.com/downloads/details.aspx?FamilyID=2BFC3187-74AA-4154-A670-76EF8BC2A0B4&displaylang=en is officially released, I am looking for a way to use new ribbon control library in my application respecting the MVVM pattern, I used ribbon 2007 repecting MVVM by extending the RibbonCommand with CanExecute and Exceute properties, but Microsoft has dumped RibbonCommand in new release. Any help on new Ribbon with MVVM is appreciated.

How to embed jquery library in ASP.NET Custom Server Control

i created custom server control using jquery. i  embeded  jquery library in the control using following code. but it displays object expected error.  has someone done this before ?   //other code    protected override void RenderContents(HtmlTextWriter output) {    output.Write("<div id=\"bckPopup\"></div>"); }   protected void onInit(EventArgs e) { Page.ClientScript.RegisterClientScriptResource(GetType(), "HelpServerControl.Scripts.jquery-1.4.1.min.js");   string javascript = "<script type='text/javascript'> " +   "$(document).ready(function () { " +   "$('#bckPopup').text(\"loaded\"); " + "});</script>" ;   if (!(Page.ClientScript.IsClientScriptBlockRegistered("bhelp" ))) Page.ClientScript.RegisterStartupScript(this.GetType(), "bhelp" , javascript); base .OnInit(e);   }      

Hosting web service inside Windows Application

  I would like to host my web service inside windows application. I prepared a short example basing on: http://msdn.microsoft.com/en-us/library/aa529311.aspx I have 2 projects created with default templates: Web Service project where I did not change anything: namespace WebService1 { [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class Service : System.Web.Services.WebService { public Service() { } [WebMethod] public string HelloWorld() { return "Hello World"; } } } Windows Project in which I changed only the main form class: public partial class Form1 : Form { public Form1() { InitializeComponent(); Uri address = new Uri("soap.tcp://localhost/TestService"); SoapReceivers.Add(new EndpointReference(address), typeof(WebService1.Service)); } } The problem is that when I compile and run this Windows Application, I can`t discover this Web Service. There must be something wrong in my solution. Could you please help me by telling what may be wrong? Thank you for help in advance.MCP

windows control library not loading webform

Hi Am using asp.net 2.0 .i am having a windows control library.dll in my webform ,but it is not loading correctly.i have attached the code below. <form id="form1" runat="server">  <object classid="http:controllibrary.dll#controllibrary.UserControl1" id= "myid" height="450" width="800" VIEWASTEXT> </object>  </form> please help me.

User Control that had been taken from external web control library (dll) doesn't see it's javascri

 Hello, I've created the .dll assembly with custom web controls and use it successfuly, but my last control needs a javascript. It is also in the same .dll with the control. The problem: My project doesn't see the javascrip in the externlal assembly. The question: How to tune the visibility of javascripts in the external assembly? Thank you. Serge.    

Using DataGrid for my application - is it the right control?

I've been investigating DataGrid for my embedded application.  Basically, what I want to do is to read in information from my embedded system over USB.  Store the information in a structure.  And, retrieve the information from the structure to display to the user.   The information I want to display is an ID Number (1-255), an ID Description, and a Relay Number.  The Relay Number is a drop down combo box with 4 options of 1-4, which is editable by the user.  The ID Number is not editable and the Grid should contain information all 1-255 IDs.  The Description should be a maximum, editable, field of 30 characters (I might change later).  Is the DataGrid the best way to do this? I tried to implement a DataGrid (see below), but am having some problems getting the data into the columns correctly.  Do I need both the Header entries in WPF and in the code?  When I do, I get two columns of 'ID #' and 'IDNum' with 1-255 in each column.  I don't want the header 'IDNum', only 'ID #' as stated in the WPF code.  I'm missing something.  Maybe someone can help.  Thanks. Sutton     <DataGrid Height="287" HorizontalAlignment="Left" RowHeight ="20" Margin="12,96,0,0" VerticalAlignment="Top" Name="PointZoneDataGrid" DataContext="{Bi
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend