I have two classes in one dll named AcadPv.dll
AcadPv.cs (Entry Point)
Code for AcadPv.cs
internal static Mutex mutexSINF = null;
public void ShowInformation()
bool IsShowInformation = true;
mutexSINF = new Mutex(false, "AcadPvShowInformation", out IsShowInformation);
if (IsShowInformation == false)
frmAssignCode fmAssignCode = new frmAssignCode();
fmAssignCode.Tag = SHOW;
fmAssignCode.Show(); //Ok ok I should call AutoDesk.AutoCad. bla bla bla . ShowModeless here
Code for frmAssignCode (In the designer file the dispose method is like the following)
protected override void Dispose(bool disposing)
if (AcadPv.mutexSINF != null)
AcadPv.mutexSINF = null;
if (disposing && (components != null))
private void btCancel_Click(object sender, EventArgs e)
DialogResult = DialogResult.Cancel;
Now the problem is
I am calling the AcadPv.dll from AutoCad. First time the Form "frmAssignCode" is opening fine. When the form is opened in the AutoCad if I want to reopen that form the form is not opening just as per the expectation (thats why I tried mutex here).
Once the form is closed (1st time) and I can not reopen the form, as "IsShowInformation" variable in "AcadPv.cs" file is always returning FALSE. Why? How to solve it?
I can not use singleton as in "AcadPv.cs (Entry Point)" there are two mthods.
1. ShowInformation (code is given above)
Both are calling same class "frmAssignCode.cs (WinForm)" with different setting and tag values. If I make "frmAssignCode.cs (WinForm)" singleton this type of architecture is not possible. I have to make separate forms for "ShowInformation" and "StoreInformation" though they will be more or less exactly same.
If I make "frmAssignCode.cs (WinForm)" singleton then both command "ShowInformation" & "StoreInformation" will invoke same instance of "frmAssignCode.cs (WinForm)" which is not desirable.
I am not sure why the mutex is not working… But I think you can resolve your issue using a “bool” variable.
static public bool bShowing = false;
public void TestShowDilaog() // This method can have any name
bShowing = true;
Form1 form = new Form1();
In the form class, identify the form closing and reset the bool variable.
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
Test.bShowing = false;
Autodesk Developer Network
Yes I can achieve that in that way, and as a matter of fact I am doing in that way already right now. But I wonder why mutex is not working.
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register
Start with some of our most frequented solutions to get help installing your software.