hi,
well half of the question I've already answered, there's no problem modifying an Application's Menustrip, you just have to send the DLL
the Apps Menustrip-object. The dropdownitems Click-Event does not work.
How I did it:
DbMenuOwner receives the MenuStrip-Object
When the DLL is loaded, I check DbMenuOwner and call AddDbMenu().
public override void Load(string databasename)
{
if (DbMenuOwner != null)
AddDbMenu();
}
The DLL-Method AddDbMenu looks like this :
protected void AddDbMenu()
{
System.Windows.Forms.ToolStripMenuItem tsmi = new System.Windows.Forms.ToolStripMenuItem();
tsmi.Text = "Database";
tsiSelect = tsmi.DropDownItems.Add("Select");
tsiSelect.Click += new EventHandler(tsiDatabaseSelect_Click);
DbMenuOwner.Items.Insert(1, tsmi);
}
public void tsiDatabaseSelect_Click(object sender, EventArgs e)
{
this.DatabaseUI();
}
When I run the Application and click the "Select"-Item, the App crashes.
Any ideas what I'm doing wrong here, or is there something missing?
One important note: I do not want to add any Code to my Application.
for your answers many thanks in advance
Franz

Franz HeynPosted Jul 31, 2024, 2:33 PM
thanks for your answer
the only difference between your suggestion and mine is the MenuStrips public state.
In my DLL I do not use a public Method instead I use a public property DbMenuOwner to pass the MenuStrip-Object to the DLL
Setting the MenuStrip public however did not solve my problem, there's still a nullreference-exception
Tuhin PaulPosted Jul 30, 2024, 2:06 PM
In your DLL, create a public method that will add the MenuItem to the MenuStrip. This method should take the MenuStrip as a parameter.
In your main project, add a reference to the DLL. In your main project, call the
AddMenuItemmethod and pass the MenuStrip as a parameter.Make the MenuStrip accessible