Kinook Software Forum

Go Back   Kinook Software Forum > Visual Build Professional > [VBP] Third Party Tools
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 09-20-2004, 12:37 AM
gribble gribble is online now
Registered User
 
Join Date: 06-04-2003
Posts: 21
custom user action - c# FolderDialog class not rendering correctly?

I have written a user defined action that calls a c# .NET windows form, displaying a GUI so the user may select options for whatever build or deployment they are running

everything has been working great for ages, however i did discover an unusual thing...

on one of my GUI forms, there is a field for a target folder. I have a browse (...) button which when pressed will show a FolderDialog control (standard inbuilt .NET control to browse the computer or network for a folder and return the foldername they have selected)

when i run my windows natively in Visual Studio, the FolderDialog form works fine, however when the form is shown through the custom action in VBPro, the "guts" of the FolderDialog control is all blank and the user cant browse for a folder.

The FileDialog control works fine it is only the FolderDialog control that is having this problem.


Im not sure really what is causing the problem except that it happens when being called from VBPro and not when being run as a normal windows forms .exe


any ideas what i can do, as forcing a user to browse to a file (then stripping the filename off to get the folder path) is annoying. In some cases the directory they may want to select doesnt have any files in it, thus no way to select it in the FileBrowser dialog
Reply With Quote
  #2  
Old 09-20-2004, 10:18 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
This problem has to do with the way the .NET FolderBrowserDialog [1] was implemented in relation to how VBP's COM threading works. The FolderBrowserDialog must execute from an STAThread (single threaded apartment), but the VBP Builder component (which instantiates custom and user actions during a build) runs in a MTAThread (multi-threaded apartment). Unless this limitation has been lifted in a .NET Framework SP, I don't believe there is currently any workaround.

One alternative would be to convert your user action into a regular .NET application that invokes VBP after all inputs have been captured, ala the ObjectModel\CSharpClient sample.


[1] http://groups.google.com/groups?q=fo...-8&sa=N&tab=wg
Reply With Quote
  #3  
Old 09-20-2004, 10:32 PM
gribble gribble is online now
Registered User
 
Join Date: 06-04-2003
Posts: 21
thanks for the response, i figured it was something inherent with how the control draws itself and there wouldnt be a simple solution

there are other reasons why i want it to be a custom action and not simply a standalone app that launches VBPro afterwards... so ill just leave it using a FileBrowse dialog and stripping the filename part off. It's not that big a deal really.... i suppose i more wanted to know why this was the case and only fix it if it could be done easily.

and i can always write my own folderbrowse dialog control if i get really keen!
Reply With Quote
  #4  
Old 02-03-2006, 05:58 AM
petrhlavka petrhlavka is online now
Registered User
 
Join Date: 02-03-2006
Posts: 5
I met the same problem and found workaround - just run FolderBrowserDialog in a separate thread with ApartmentState set to STA.

http://www.csharpfriends.com/Forums/...x?PostID=33503
Reply With Quote
  #5  
Old 02-03-2006, 06:37 AM
gribble gribble is online now
Registered User
 
Join Date: 06-04-2003
Posts: 21
hey cool a response after all this time

I hadnt bothered doing anything about it since it was such a low priority thing, and back then googling etc didnt find any obvious answers

thanks for the info, i can easily fix it now
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT -5. The time now is 05:50 AM.


Copyright © 1999-2023 Kinook Software, Inc.