|
|
Thread Tools | Rate Thread | Display Modes |
#1
|
|||
|
|||
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 |
#2
|
|||
|
|||
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 |
#3
|
|||
|
|||
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! |
#4
|
|||
|
|||
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 |
#5
|
|||
|
|||
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 |
|
|