Forum Discussion

cnsbusaaras's avatar
cnsbusaaras
Ideator I
2 years ago

How to load aras 2023 dll with cpp host cli without native net core?

[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:4aacaea8-0c4c-471c-aefc-402fbf171d8a:type=text&text=%23using%20%22C%3A%2Ftemp%2Faras2023dlls%2Fbin%2FIOM.dll%22%0D%0A%23using%20%22C%3A%2Ftemp%2Faras2023dlls%2Fbin%2FSystem.Configuration.ConfigurationManager.dll%22%0D%0A%23using%20%22C%3A%2Ftemp%2Faras2023dlls%2Fbin%2FAras.Net.dll%22%0D%0A%0D%0Ausing%20namespace%20System%3B%0D%0Ausing%20namespace%20System%3A%3AIO%3B%0D%0Ausing%20namespace%20System%3A%3AReflection%3B%0D%0Ausing%20namespace%20System%3A%3AConfiguration%3B%20%20%0D%0A%0D%0A%0D%0Avoid%20arasDo%28%29%0D%0A%7B%0D%0A%20%20%2F%2F%20sample%20aras%20code%0D%0A%20%20System%3A%3AString%20%5E%20url%20%3D%20%22http%3A%2F%2Fdevaras2023%2FInnovatorServer%2FServer%2FInnovatorServer.aspx%22%3B%0D%0A%20%20System%3A%3AString%20%5E%20database%20%3D%20%22InnovatorSolutions%22%3B%0D%0A%20%20System%3A%3AString%20%5E%20user%20%3D%20%22admin%22%3B%0D%0A%20%20System%3A%3AString%20%5E%20password%20%3D%20%22innovator%22%3B%0D%0A%0D%0A%20%0D%0A%20%20auto%20conn%20%3D%20Aras%3A%3AIOM%3A%3AIomFactory%3A%3ACreateHttpServerConnection%28url%2C%20database%2C%20user%2C%20password%29%3B%0D%0A%20%20auto%20result%20%3D%20conn-%3ELogin%28%29%3B%0D%0A%20%20auto%20s%20%3D%20result-%3EToString%28%29%3B%0D%0A%7D%0D%0A%0D%0Astatic%20Assembly%20%5E%0D%0A%20%20LoadFromSameFolder%28Object%20%5E%20sender%2C%20ResolveEventArgs%20%5E%20args%29%20%7B%0D%0A%20%20%20%20String%20%5E%20folderPath%20%3D%20%22C%3A%5C%5Ctemp%5C%5Caras2023dlls%5C%5Cbin%22%3B%0D%0A%20%20%20%20String%20%5E%20assemblyPath%20%3D%20Path%3A%3ACombine%28folderPath%2C%20%28gcnew%20AssemblyName%28args-%3EName%29%29-%3EName%20%2B%20%22.dll%22%29%3B%0D%0A%20%20%20%20if%20%28File%3A%3AExists%28assemblyPath%29%20%3D%3D%20false%29%0D%0A%20%20%20%20%20%20return%20nullptr%3B%0D%0A%20%20%20%20Assembly%20%5E%20assembly%20%3D%20Assembly%3A%3ALoadFrom%28assemblyPath%29%3B%0D%0A%20%20%20%20return%20assembly%3B%0D%0A%20%20%7D%0D%0A%0D%0Avoid%20aras%28%29%0D%0A%7B%0D%0A%20%20%2F%2F%20put%20this%20somewhere%20you%20know%20it%20will%20run%20%28early%2C%20when%20the%20DLL%20gets%20loaded%29%0D%0A%20%20System%3A%3AAppDomain%20%5E%20currentDomain%20%3D%20AppDomain%3A%3ACurrentDomain%3B%0D%0A%20%20currentDomain-%3EAssemblyResolve%20%2B%3D%20gcnew%20ResolveEventHandler%28LoadFromSameFolder%29%3B%0D%0A%20%20arasDo%28%29%3B%0D%0A%7D]

The exePath does not exist
Assembly.GetEntryAssembly() returns a NULL
Can someone explain me how to execute the added cpp sample code so I can load the aras 2023 dlls?

2 Replies

  • Have you seen the cpp sample in the 2023 Programmers Guide? According to the guide the dll must be registered in the Windows Registry and you need to reference COM to your project.

    There are also some older cpp samples in the forum, but I am not sure if the work anymore.

    • cnsbusaaras's avatar
      cnsbusaaras
      Ideator I

      Hello Angelalp,
      thank you for your reply.
      The solution with COM reference does not function in our case.
      We try to load the aras 2023 dll with CPP/CLI windows exe.