0

I have a very simple code below to get CATIA object. When I create a project with NET Framework 4.8, there is no issue, I can get the CATIA application and start working with it. However, when I use NET 6.0 project, I get “Object reference not set to an instance of an object

Dim CATIA as Object
CATIA = GetObject(,"CATIA.APPLICATION")
MessageBox.Show(CATIA.ActiveDocument.Name)

Does anyone have some idea if this can be fixed with NET 6.0 or I will stuck with NET Framework?

N.TW12
  • 241
  • 2
  • 11
  • Try to use Marshall ? Dim CATIA As INFITF.Application CATIA = System.Runtime.InteropServices.Marshal.GetActiveObject("CATIA.Application"). – Disvoys Aug 31 '23 at 06:53
  • I'd highly recommend you move your .Net Framework code into .Net 6 Core. Almost everything is the catered for, alas with slightly different implementations but its all well documented. Keeping a codebase with a mix of frameworks isn't best business practice and often leads to dependency rot. Also upgrading it to core will mean you can run it on Linux or Mac. – Jeremy Thompson Aug 31 '23 at 07:47
  • @JeremyThompson, I am moving away from Framework but I encounter the very 1st issue - this one. – N.TW12 Aug 31 '23 at 13:01
  • @Disvoys, there is no ‘GetActiveObject’ - I am using NET 6.0 – N.TW12 Aug 31 '23 at 13:08
  • Try to make your own function Marshall. You will find this function easily in Google. Then you will have thé GetActiveObject. I'm also using .net 6. If it Can help, a sample : https://chat.openai.com/share/3f361a43-31b7-4093-ad96-5728ae7df5e9 – Disvoys Sep 01 '23 at 23:28

0 Answers0