Custom Component

  • Thread starter Thread starter Fred Chen
  • Start date Start date
F

Fred Chen

Hi,

I've created a custom component.

I would like my component to reference the runtime assembly when it is
added to a form. (The reason for this is because my component in the
design-time assembly is derived from the Component class, and I don't
want to expose that class to the user)

For the CompactFramework you can use the RuntimeAssemblyAttribute in
System.CF.Design.

Is there a simular attribute that is that can be used in the full
Framework?

Thanks,
Fred
 
Fred said:
I would like my component to reference the runtime assembly when it is
added to a form. (The reason for this is because my component in the
design-time assembly is derived from the Component class, and I don't
want to expose that class to the user)

I don't understand, your component at runtime should also derive from
Component, otherwise it is not a component! If you don't derive from
Component you don't get features that the runtime container and the control
need (for example Dispose()).

Your control can behave differently at designtime and runtime by checking
the Component.DesignMode property. For example, at runtime your component
could access a remote machine, but at design time it could simulate the
connection.
For the CompactFramework you can use the RuntimeAssemblyAttribute in
System.CF.Design.

The reason for this is that the compact framework is a totally different
framework to the desktop version, so you need two versions of the control:
one that the compact framework will accept so you can test the component on
the actual smart device; the other version is used in the designer which
cannot use the compact framework version because it runs on the desktop.
Is there a simular attribute that is that can be used in the full
Framework?

not that I know of, but then again, I don't understand that there is a
reason for it

Richard
 
Hi Richard,

Thanks for your quick response.

I need to reference a runtime assembly because my component uses the DTE
object to initialize properites in the component using the current
project's properties (the project it is being added to).

When I run a test application that uses my component, I get an exception
saying I can't reference the current DTE object.

When I remove the designer assembly from the reference list, after
adding the component, and add the runtime assembly the test application
works fine.

The runtime assembly is the designtime assembly with the code that uses
the DTE object removed.

This is why I need to use designtime and runtime assemblies.

Any ideas on how to add the runtime assembly instead of the designtime
assembly to the reference list?

Thanks,
Fred
 
Back
Top