Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I created a clr empty project that uses a ui, then is called a c# library, but I have problem with OpenFileDialog in c# library..sotware get into loop..Do you have an idea? tHIS is code of my main in c++:

<pre>#using "consume_cs_indexers.dll" //c# library

using namespace System;

#include "MyForm.h"

using namespace Project702;

int main()
{
	IndexerClass ^ ic = gcnew IndexerClass;
	//ic->default[0] = 21;
	//for (int i = 0; i <= 10; i++)
	//	Console::WriteLine("Element #{0} = {1}", i, ic->default[i]);

	int result = ic->Add(3, 6);


	System::String^ s = result.ToString();

	MyForm ^ fm = gcnew MyForm;

	//fm->Pr


	fm->MyString2 = s;
     fm->ShowDialog();

	ic->PrintLabelAction();

	//fm->ShowDialog();
}





code in my library c#:

public void PrintLabelAction()
   {
       OpenFileDialog openFileDialog = new OpenFileDialog();
       openFileDialog.Filter = "DYMO files |*.label;*.dymo|All files|*.*";

       var FileName = "";


       //var LabelObjects = "";
       if (openFileDialog.ShowDialog() == true) // in this raw code get into a loop
       {


What I have tried:

I tried to do call stack but is empty..
Posted
Updated 10-Mar-23 4:59am
v2
Comments
Richard Deeming 10-Mar-23 10:43am    
So you want us to help you fix a problem you can't describe in code we can't see running on a system we can't access?

That's not going to work. Click the green "Improve question" link and update your question to include a clear and complete description of the problem, the relevant parts of your code, and the full details of what you have tried and where you are stuck.
Member 14594285 10-Mar-23 10:59am    
done
Jo_vb.net 10-Mar-23 11:32am    
Your If statement is fulfilled when then dialog button ok is pressed - not earlier.

Perhaps this example helps:

dialog.ShowDialog();
if (string.IsNullOrEmpty(dialog.FileName))
return default;
string FileName = Path.GetFileName(dialog.FileName);
Member 14594285 10-Mar-23 11:41am    
it's the same thing..in dialog.ShowDialog() software get into a loop
Jo_vb.net 10-Mar-23 12:02pm    
When you have the file name you will do some more instructions.
OK button will be pressed at some time...
Then:
return default;

string FileName = Path.GetFileName(dialog.FileName);

// more instructions

// OK button is pressed

return default;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900