Search code examples
c#.netsolidworks

Can't find the replacement for EntryPoint Attribute in .net 4.7


So i am trying to update the solidoworks macro from .net 3.5 to .net 4.7

And when i was about to do that, i found that there is a method called EntryPoint(0) which basically is the start point for the macro code.

Adding the code below:

using Microsoft.VisualStudio.Tools.Applications.Contract;
using Microsoft.Office.Tools.Excel;
using Microsoft.Office.Tools;
using SolidWorks;
using SolidWorks.Interop.sldworks;
using System;
using static System.Reflection.MethodInfo; 
using System.Runtime.InteropServices;
using System.AddIn.Contract.Collections; 
using System.ComponentModel;
using System.Diagnostics;
using System.Management;
using System.Runtime;
using System.Runtime.InteropServices.ComTypes;
using System.Windows.Forms;

namespace GoPublish.csproj
{
    public sealed class SolidWorksMacro : OuterDispProxy
    {
      [EntryPoint(0)]
      public SldWorks swApp;

      [DllImport("ole32.dll")]
      private static extern int CreateItemMoniker([MarshalAs(UnmanagedType.LPWStr)] string lpszDelim, [MarshalAs(UnmanagedType.LPWStr)] string lpszItem, out IMoniker ppmk);

      [DllImport("ole32.dll")]
      private static extern int GetRunningObjectTable(uint reserved, out IRunningObjectTable pprot);

I am not able to find a replacement of that in the .net 4.7

Any suggestions as to how can i do that?


Solution

  • Class EntryPointAttribute is defined in the Microsoft.VisualStudio.Tools.Applications.Contract.dll, which is a part of VSTA (Visual Studio Tools for Applications). I'm not too familiar with it but my understanding it's a lightweight version of VS for macro/plugin development.

    You definitely can build solidworks macros without this dll, but there are a lot of ways to build macros, so maybe with your specific setup you do need it.

    I'm guessing you've been using VSTA for your 3.5 version and switched to VisualStudio for 4.7 and that's your actual issue.

    .net 4.7 has full support for the libraries build for previous versions, so you can try adding the reference manually. Here's where I was able to find Microsoft.VisualStudio.Tools.Applications.Contract.dll : C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.Tools.Applications.Contract\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Tools.Applications.Contract.dll