Click here to Skip to main content
15,892,839 members
Home / Discussions / C#
   

C#

 
GeneralRe: Decoding method Pin
harold aptroot21-Aug-14 4:46
harold aptroot21-Aug-14 4:46 
GeneralRe: Decoding method Pin
PIEBALDconsult21-Aug-14 4:55
mvePIEBALDconsult21-Aug-14 4:55 
GeneralRe: Decoding method Pin
Bernhard Hiller21-Aug-14 21:43
Bernhard Hiller21-Aug-14 21:43 
GeneralRe: Decoding method Pin
PIEBALDconsult22-Aug-14 3:20
mvePIEBALDconsult22-Aug-14 3:20 
QuestionRe: Decoding method Pin
jojoba2021-Aug-14 6:42
jojoba2021-Aug-14 6:42 
AnswerRe: Decoding method Pin
OriginalGriff21-Aug-14 8:04
mveOriginalGriff21-Aug-14 8:04 
QuestionRe: Decoding method Pin
jojoba2021-Aug-14 9:45
jojoba2021-Aug-14 9:45 
AnswerRe: Decoding method Pin
Eddy Vluggen21-Aug-14 9:53
professionalEddy Vluggen21-Aug-14 9:53 
AnswerRe: Decoding method Pin
Bernhard Hiller21-Aug-14 21:46
Bernhard Hiller21-Aug-14 21:46 
Questionsplit string into line C# Pin
Member 1054819721-Aug-14 3:05
Member 1054819721-Aug-14 3:05 
AnswerRe: split string into line C# Pin
OriginalGriff21-Aug-14 4:07
mveOriginalGriff21-Aug-14 4:07 
GeneralRe: split string into line C# Pin
PIEBALDconsult21-Aug-14 5:32
mvePIEBALDconsult21-Aug-14 5:32 
QuestionWindows Form KeyDown Pin
Zeyad Jalil21-Aug-14 0:06
professionalZeyad Jalil21-Aug-14 0:06 
AnswerRe: Windows Form KeyDown Pin
Eddy Vluggen21-Aug-14 0:34
professionalEddy Vluggen21-Aug-14 0:34 
AnswerRe: Windows Form KeyDown Pin
joost.versteegen21-Aug-14 2:58
joost.versteegen21-Aug-14 2:58 
GeneralRe: Windows Form KeyDown Pin
Rob Philpott21-Aug-14 6:25
Rob Philpott21-Aug-14 6:25 
QuestionMobile Money Transfer Application Pin
Soren Neilsen20-Aug-14 22:42
Soren Neilsen20-Aug-14 22:42 
AnswerRe: Mobile Money Transfer Application Pin
OriginalGriff20-Aug-14 22:44
mveOriginalGriff20-Aug-14 22:44 
QuestionOpenFileDialog works from app but not from a spawned thread after use InvokeMember to load assembly / class Pin
JudyL_MD20-Aug-14 10:41
JudyL_MD20-Aug-14 10:41 
I've stripped my problem down to the bare minimum. I've got a form that, in response to user action, needs to display the OpenFileDialog dialog. When this form is started "normally" i.e. using Application.Run, the dialog appears. When this form is started via reflection it fails. Fails in this case means that the code successfully runs all the way to the actual OpenFileDialog.ShowDialog call -- ShowDialog is stepped into but the dialog never appears and the call never returns.

Here's the code:
The direct app:

C#
using UiLibrary;
namespace DirectApp
{
  static class Program
  {
    [STAThread]
    static void Main ()
    {
      Application.EnableVisualStyles ();
      Application.SetCompatibleTextRenderingDefault (false);
      Application.Run (new Form1 ());
} } }

The indirect app:
C#
namespace IndirectApp
{
  public partial class DummyFormToLaunchTheRealUI
  {
    public DummyFormToLaunchTheRealUI () { InitializeComponent (); }

    private void button1_Click (object sender, EventArgs e)
    {
      Assembly abs = Assembly.LoadFile (@"C:\temp\tester\UiLibrary\bin\debug\UiLibrary.dll");
      Type startType = abs.GetType ("UiLibrary.Startup", true);
      object startLib = startType.InvokeMember ("", BindingFlags.CreateInstance, null, null, new object[0]);
      startType.InvokeMember ("Run", BindingFlags.InvokeMethod, null, startLib, new object[0]);
} } }

The library:
namespace UiLibrary
{
  public class Startup
  {
    public void Run ()
    {
      Thread runThread = new Thread (new ThreadStart (ActualWork));
      runThread.Start ();
    }

    private void ActualWork ()
    {
      Form1 f = new Form1 ();
      f.ShowDialog ();
    }
  }

  public partial class Form1 : Form
  {
    public Form1 () { InitializeComponent (); }

    private void button1_click (object sender, EventArgs e)
    {
      OpenFileDialog ofd = new OpenFileDialog ();
      // this field always correct
      ofd.InitialDirectory = Environment.ExpandEnvironmentVariables (@"%USERPROFILE%\Downloads");
      // doesn't change if call ShowDialog with no paramters
      ofd.ShowDialog (this);
} } }

I've got to show Form1 from the library in its own thread since I want IndirectApp to remain responsive to UI. This is stripped down - in my real code Form1 is much more complex, successfully launching its own forms and doing other stuff regardless of which method is use to fire it up.

Visual Studio 2012 using .NET 3.5 on Windows 7 SP1

Any ideas on what's particular to the OpenFileDialog class? This is the only one of the common dialogs that is used.
Thanks all!
Judy
Be wary of strong drink. It can make you shoot at tax collectors - and miss.
Lazarus Long, "Time Enough For Love" by Robert A. Heinlein

AnswerRe: OpenFileDialog works from app but not from a spawned thread after use InvokeMember to load assembly / class PinPopular
Richard Deeming20-Aug-14 10:59
mveRichard Deeming20-Aug-14 10:59 
GeneralRe: OpenFileDialog works from app but not from a spawned thread after use InvokeMember to load assembly / class Pin
JudyL_MD20-Aug-14 11:04
JudyL_MD20-Aug-14 11:04 
GeneralRe: OpenFileDialog works from app but not from a spawned thread after use InvokeMember to load assembly / class Pin
Ravi Bhavnani20-Aug-14 11:12
professionalRavi Bhavnani20-Aug-14 11:12 
QuestionSolution for Oracle.DataAccess.Client.OracleException Pin
Member 1099617820-Aug-14 2:25
Member 1099617820-Aug-14 2:25 
AnswerRe: Solution for Oracle.DataAccess.Client.OracleException Pin
Richard MacCutchan20-Aug-14 3:09
mveRichard MacCutchan20-Aug-14 3:09 
AnswerRe: Solution for Oracle.DataAccess.Client.OracleException Pin
Dave Kreskowiak20-Aug-14 4:09
mveDave Kreskowiak20-Aug-14 4:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.