0

I'm trying to register my Classlib.dll for using COM interop with the regasm.exe tool. In general this is not a problem.

like this: > regasm.exe MyAsm.dll /tlb: MyAsm.tlb

But now I use a .dll reference in my classlib project. The general registration still works but then the dll reference gets lost and the functions are useless.

I'm sure there is a simple solution for this as the automatic registration via VisualStudio Build settings works fine.

So how can I manually adjust my script?

My current approaches are:

  1. uing the option: regasm /asmpath
  2. use of the tools: Tlbexp.exe, Tlbimp.exe

My current information sources:

Since the documentaries are unfortunately very limited and I am new to the COM topic it would be great if you could help me.

  • 1
    What do you mean by _"But now I use a .dll reference in my classlib project...dll reference gets lost"_? Which DLL? Which classlib? If you are talking about project B depending on project A (your COM library) you should be adding a COM reference to A not file reference and not a project reference. Otherwise you get into pathing problems, something that COM doesn't use as a first class citizen. COM references are via the registry and COM clients need not know where the DLL is located –  Jun 03 '20 at 12:46
  • I am using a dll wich provides funktions of the Dijkstra Algorithm (by Mateusz Mazurek) – Alexander Ellmann Jun 03 '20 at 13:27
  • netstandard1.3;net40 1.2.1 Mateusz Mazurek https://github.com/matiii/Dijkstra.NET – Alexander Ellmann Jun 03 '20 at 13:28
  • "If you are talking about project B depending on project A (your COM library) you should be adding a COM reference to A not file reference and not a project reference. Otherwise you get into pathing problems, something that COM doesn't use as a first class citizen. COM references are via the registry and COM clients need not know where the DLL is located" Yes that's exactly right ! – Alexander Ellmann Jun 03 '20 at 13:29
  • Right now I am trying to add the COM reference in my project.. – Alexander Ellmann Jun 03 '20 at 13:33
  • You forgot the `/codebase` option. Without it, you must install the DLL into the GAC so it can be found. Which is a good idea on the user's machine, not on yours. – Hans Passant Jun 03 '20 at 13:41
  • FYI: the source code from the referenced dll A is not 100% COM compatible, there are several warnings e.g. that generic types are found during manual registration. > regasm.exe Dijkstra.NET.dll /tlb: Dijkstra.NET.tlb /codebase Maybe it is also interesting, that in project A no target framework is and the automatic COM-interop registration is not selectable. – Alexander Ellmann Jun 03 '20 at 14:03
  • @Hans Passant: Thats right. Is it easier to register assemblies in GAC? – Alexander Ellmann Jun 03 '20 at 14:09
  • so after I registered the assembly (according to the VS dev prompt) with: > regasm.exe Dijkstra.NET.dll /tlb: Dijkstra.NET.tlb /codebase I cannot find it in my VS COM references. Maybe I am missing something or have a mistake in my thinking. Do I have to add the COM data annotation like [ComVisible(true)] etc. in the source code? Usually if I don't have the source code and only the dll it should work as well, right? And after all, VS does it automatically when I choose it in the build options and use the Assembly via file reference. – Alexander Ellmann Jun 03 '20 at 14:28

0 Answers0