I'm working in vb.net in Visual Studio 2017. I'm fairly new to visual basic. I'm more familiar with VBA.
I prototyped code to access Autodesk Vault 2019, download a file, and open it in Autodesk Inventor 2019. This code was created with an Autodesk Inventor AddIn template in visual studio. The code compiled without errors and functioned as intended.
The final intention of this application is to compile the code to a DLL and then call that DLL (with arguments) from VBA in another piece of software (CorelDraw). In order to do this it is my understand that I need to place the code in a class library template in order to have it compile to a DLL correctly.
While doing this, I have an issue with the following line of code:
ActiveInvApp = Marshal.GetActiveObject("Inventor.Application")
"Marshal" is from "System.Runtime.InteropServices" which is imported at the beginning of the application with the following line of code:
Imports System.Runtime.InteropServices
The issue is that Visual Studio doesn't recognize "GetActiveObject". It highlights it with a red squiggly line. When I hover over it with the cursor it shows the tooltip: "'GetActiveObject' is not a member of 'Marshal'".
At the time of writing this I have two instances of Visual Studio 2017 open. One with the class library version of this code and one with the Autodesk Inventor AddIn version. The AddIn version does not have a problem with this line of code and the class library does.
Per some instructions on creating a DLL class library, my code starts with the following:
Namespace VaultCOMFunctions
Public Module StringLibrary
<Extension>
Public Sub OpenFromVault(PartNum As String)
'Code for opening the file goes here
I'm not sure if that's relevant or not. Like I said, I'm somewhat new to VB.net.
I've spent a good deal of time messing around with references to try to clear this up, but with no luck. What could be causing this? I can't find any existing forum posts (here or elsewhere) with any kind of a similar issue.
The answer was posted by @Simon_Mourier in the comments on the original post. The Visual Studio project was targeting .NET Core. To fix the issue I simply switched the project to target .NET Framework and the error went away.