burakd,
Unfortunately VSTA does not allow add-ins to use the "new" operator. The easiest way to create a new object is to include an accessible method in your host that creates and returns a new object. Below is a snippet from our EventSample that shows how to do this.
I hope this helps. Please let me know if you have anymore questions.
-MelodyI) Declaring Objects in VSTA
VSTA cannot access constructors from the host application. The constructors included in the proxy file are for internal use only. To
create an object in VSTA, a public method must be available in the
add-in entry point, in this case the MainApplication class, which
constructs the object, then returns it. The code below shows an object class, MainObject, the MainApplication class, and an add-in. In the MainApplication class, the method NewObject is used by the add-in to create a MainObject in the add-in.
//host application
namespace Sample
{
//simple object used by main application
public class MainObject
{
private string message;
public string Message
{
get
{
return message;
}
}
public MainObject(string messageIn)
{
message = messageIn;
}
}
//Main Application class
public partial class MainApplication
{
public MainObject NewObject(String inMessage)
{
MainObject thisObject = new MainObject(inMessage);
return thisObject;
}
}
}
//add-in
namespace SampleProject1
{
public partial class AddIn
{
private void AddIn_Startup(object sender, EventArgs e)
{
//add a message to the display box
EventSample.MainObject thisObject = this.NewObject("Add In- Object");
}
}
}