Pretty new to c# and MVC. I've got a MVC application setup in which a webapp runs under a chrome like browser control. I have button inside the webapp (html) from which user able to select folders he wants, then I want the actual path of them.
For that I am making an ajax request to my MVC controller which will open folderBrowserDialog (System.Windows.Forms) then returning path back as the ajax response. Everything works fine when I run the application with visual studio. But after making the package of the application and installing the exe, the folderBrowserDialog isn't appearing at all. There are no errors thrown the ajax respons, properly with a value null
here is the code (part of it )
selectFolderGlobal is a global variable
public JObject OpenFolderExplorer()
{
try
{
Thread fb= new Thread(new ThreadStart(openFileBrowser), 1);
fb.SetApartmentState(ApartmentState.STA);
fb.Start();
fb.Join();
JObject selectedFolder = new JObject();
selectedFolder.Add("selectedFolder", selectedFolderGlobal);
return selectedFolder;
}
catch (Exception ex)
{
Logger.Log(" Exception: " + ex.Message);
JObject errorcode = JObject.Parse(mConstants.EXCEPTION);
return errorcode;
}
}
private void openFileBrowser()
{
try
{
var fbd= new FolderBrowserDialog();
fbd.ShowNewFolderButton = false;
DialogResult result = fbd.ShowDialog(new Form() { TopMost = true, WindowState = FormWindowState.Minimized });
if (result == DialogResult.OK)
{
selectedFolderGlobal= fbd.SelectedPath;
}
}
catch (Exception ex)
{
Logger.Entry(" Exception: " + ex.Message);
}
}
Ajax response comes back like this
{
"selectedFolder":null
}
Anybody has a clue why it might be happening only after the package creation ( after making an .exe out of it) ? The System.Windows.Forms.dll is added to the dependancy ( if it wasn't it should've thrown an exeption or even the package build would've been failed)