Can a Registration-Free COM component be used without registering it on the development machine?

StackOverflow https://stackoverflow.com/questions/6351226

  •  28-10-2019
  •  | 
  •  

سؤال

I have a Registration-Free COM component I developed that is working fine on target machines without needing to register the component. It is in a dll that has tlb embedded, and an RT_MANIFEST resource that has the manifest that lists the assembly dependencies and CLSIDs for the component.

In Visual Studio(2008) I still need to register this COM component to do at least two things I have tried. When adding a reference to the component, I cannot select the isolated property for the reference unless the component is registered. I also can not create instances of the object when the debugger is running unless the component is registered. I can however add the reference and compile the application and run it without registering the component.

Is there some way to use a Registration-Free COM component in Visual Studio without registering it, or does it have to be registered on the development machine for everything to work correctly?

هل كانت مفيدة؟

المحلول

It is important here to understand the difference between compile-time and run-time use of a COM component. Reg-free COM is purely a runtime feature. The manifest you write that describes the COM interface is the registration-free part. You don't have to register the COM component in the machine's registry. You supply the registration information in a file instead. Which means you don't need an installer. Which also means that you are insulated from registration problems. Better known as DLL Hell.

The keys in the registry, or the entries in the manifest, are important to help COM figure out what DLL needs to be loaded when the COM client asks it to create an instance of the COM object.

This is very distinct from compile-time. A type library is very helpful to tell the compiler whether or not you wrote correct code. Does the COM component really have a IFoo interface? Does the IFoo interface really have a Mumble() method that takes two arguments? The type library tells the compiler what the interface looks like and allows the compiler to do a static check on the code you wrote. Distinct from 'late-binding' btw, an option that allows you to write COM client code without a type library (and thus without type checking). Common in scripting languages.

Reiterating: registration-free COM is purely about installation, not about writing code.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top