(MVC) MVC (2017 год)

COM-component for classic ASP (eng).

COM-component for classic ASP

There are millions sites building on Classic ASP. No heroes to rewriting its on modern technology Classic ASP.NET or Classic ASP.NET MVC. But this category of sites should be upgrade and modernize. Today there are only one way to upgrade that sites - create COM VISIBLE component in .NET framework. Alternative way is to use outdated VB6 studio.

But how to create ComVisible component? Let's follow to me, please.

First of all, I create simple Class Library project and add to my project interface definition.



This GUID key I have generatedrandomly, and .ComInterfaceType has four value, in my opinion best choice is InterfaceIsDual.

  • InterfaceIsDual - Indicates that the interface is exposed to COM as a dual interface, which enables both early and late binding. InterfaceIsDual is the default value.
  • InterfaceIsIDispatch - Indicates that an interface is exposed to COM as a dispinterface, which enables late binding only.
  • InterfaceIsIInspectable - Indicates that an interface is exposed to COM as a Windows Runtime interface.
  • InterfaceIsIUnknown - Indicates that an interface is exposed to COM as an interface that is derived from IUnknown, which enables only early binding.

Next step of this project is to create class, that Implements interface above and IDisposable. About realization IDisposable there are big question, because .NET Framework includes million of code string to clear memory. Maybe best way to clear memory is to use in ASP page one string of code MyObject=nothing, this one induce a automatically clear memory. But in this my component using big memory buffer and I clear memory manually by my own code in Dispose part of class.



You may see in code above that I used four attributes, main of it is ProgId, GUID number of interface is generated randomly, but ClassInterfaceType is a big question too. At common it can take three values, in my opinion AutoDispatch is a best choice.

  • AutoDispatch - Indicates that the class only supports late binding for COM clients. A dispinterface for the class is automatically exposed to COM clients on request. The type library produced by Tlbexp.exe (Type Library Exporter) does not contain type information for the dispinterface in order to prevent clients from caching the DISPIDs of the interface. The dispinterface does not exhibit the versioning problems described in ClassInterfaceAttribute because clients can only late-bind to the interface.
  • AutoDual - Indicates that a dual class interface is automatically generated for the class and exposed to COM. Type information is produced for the class interface and published in the type library. Using AutoDual is strongly discouraged because of the versioning limitations described in ClassInterfaceAttribute.
  • None - Indicates that no class interface is generated for the class. If no interfaces are implemented explicitly, the class can only provide late-bound access through the IDispatch interface. This is the recommended setting for ClassInterfaceAttribute. Using ClassInterfaceType.None is the only way to expose functionality through interfaces implemented explicitly by the class.

Next step is simple test your code without COM-VISIBLE interface. For this purpose I had created simple console application and test main algorithm of my component.



Also you may to chech exported interface and method by Visual Studio tools.



All working fine and I going to next step to check Comvisible interface opportunity.


First off all need to strong sign your .NET assembly. It's a extremely simple task, if you can not plain to spread your assembly public. Let's go to the property of project with assembly and sign it by one click.



Next step should be applied in target computer with web-server, but in my developer computer I need to use this step for testing too.



After that need to check success of registration, this is goal of all previous steps. For this purposes I use OLE-COM Object Viewer.



You may see above we have success. But there are another good alternative OleViewDotNet, it working fine and we may see a our Com-object in windows registry too.



Now we are getting close and close to finally complex testing. One way is to create simple web-project with ASP page.



But Cassini Developer's web server has full unsupported Classic ASP page and alternative way is simple using Notepad++ to create test of our Com-component.

After that need to check that your system has support Classic ASP technology. There are two main point you need to check, first of it - Classic ASP page is supported in your installation and second point - IIS has handler (ISAPI Filter) to process ASP page.



If computer has Classic ASP support, you need only simple configure IIS nodes to test page.



And after that let's go to this IIS Node.



In this case my component resizing image with saving historical interface of all component and simple new opportunities, you may see in screen above image resizing successfully. In foreground I show as reminder important point of development Com-Visible object - you must register you object in windows registry.





Comments ( )
<00>  <01>  <02>  <03>  <04>  <05>  <06>  <07>  <08>  <09>  <10>  <11>  <12>  <13>  <14>  <15>  <16>  <17>  <18>  <19>  <20>  <21>  <22>  <23
Link to this page: //www.vb-net.com/ClassicAspService/index.htm
<SITEMAP>  <MVC>  <ASP>  <NET>  <DATA>  <KIOSK>  <FLEX>  <SQL>  <NOTES>  <LINUX>  <MONO>  <FREEWARE>  <DOCS>  <ENG>  <CHAT ME>  <ABOUT ME>  < THANKS ME>