1

Can I have Main with some different type argument like object type or anything else. Like in this case I want this

  static void Main(Mtb.Application app)
  {...}

But it is giving me error

Error 1 Program 'C:\Users\abc\documents\visual studio 2010\Projects\testmin\testmin\obj\x86\Debug\Abc.exe' does not contain a static 'Main' method suitable for an entry point Abc

So, I want to ask, cant I use differnt type in main method other than string.

Thanks

Waqar Ahmed
  • 5,005
  • 2
  • 23
  • 45

2 Answers2

4

So, I want to ask, cant I use differnt type in main method other than string.

No, you can't. The arguments to the Main method are the ones passed on the command line, so it can only be an array of strings. How would you pass a Mtb.Application on the command line anyway?

Thomas Levesque
  • 286,951
  • 70
  • 623
  • 758
  • ok fine sir. Is there any other way so that I can pass my mtb object in application. I am really struggling this for a week now. – Waqar Ahmed Sep 27 '14 at 12:24
  • @WaqarAhmed, well, where does this object come from? Another program? – Thomas Levesque Sep 27 '14 at 12:25
  • yeah..actually i am creating minitab addin.and i want to pass minitab object to my application.I tried to add my form in addin but it gives me error. thats why i am now trying to call my application using Process class. – Waqar Ahmed Sep 27 '14 at 12:27
  • when i tried to add my form in addin it gives me error that you can see here. No one gives the answer to that question you can see error here ..http://stackoverflow.com/questions/26034337/active-analysis-throws-divide-by-zero-exception – Waqar Ahmed Sep 27 '14 at 12:28
  • @WaqarAhmed, you can't just pass an object to another process like that, it doesn't work that way. If it was an object representing data, you could serialize it and pass the file, but in this case it's the Minitab application, and it doesn't make sense to serialize it. Your plugin has to run in the same process as Minitab to be able to access the Application object. – Thomas Levesque Sep 27 '14 at 12:36
  • To solve the problem in your other question, I suggest you contact the ActiveAnalysis support, as it seems the problem is in their product. – Thomas Levesque Sep 27 '14 at 12:37
  • ok thanks for your detail information. I post the same problem on their forum as well. but they didnt replied yet, I hope they reply soon. But thanks for your answer and guidance. – Waqar Ahmed Sep 27 '14 at 12:39
1

Any of Windows Application or Console Application should have a static void Main() or static void Main(string[] args), then your Main method is not a Entrance Point of .net application, this is just another overload of the original Main method.

if you want to pass a sth other than string to an application, you just save it to some where and pass the address of it to your app. then your answer is NO

Mehdi Khademloo
  • 2,754
  • 2
  • 20
  • 40