Groups | Blog | Home
all groups > dotnet clr > november 2004 >

dotnet clr : Can't import .OCX assembly into Web Matrix Project.Hi,


Jason Robertson
11/29/2004 2:33:41 AM
Hi,

I am using Web Matrix Project as .NET programming environment. Can you show
me detailed steps how to import the .ocx library into the Web Matrix
Project. I can't seem to be able to import other assembly than .dll, .exe or
..mcl . I am pretty new to the .NET programming environment, and may be
missing something.

I can see the file in C:\Program Files\Common Files\Tops\xyzxyz.ocx , but I
can't find a way to import it into the Web Matrix Project to see all Methods
and Properties of the assembly.

Thank you for any help.

Shanku Niyogi (MS)
12/17/2004 7:59:03 AM
You can import an .OCX into your ASP.NET project, and use it as a component,
by first wrapping it in a .NET interop assembly. However, if you have a
visual .OCX (a control you can use on a VB form), you cannot use it visually
in an ASP.NET page.

To use an .OCX component in your project, use the following steps:

1) Install the .NET Framework SDK, if you haven't already.
2) Open a Windows command prompt, and go into the directory where the OCX is
stored.
3) Run the following command line:

"c:\program files\microsoft.net\sdk\v1.1\bin\tlbimp.exe" ocxname.ocx

where ocxname.ocx is the name of the OCX. Note: If your SDK was installed
somewhere other than above, you'll need to change the path to the tlbimp.exe.
4) The tlbimp tool will inspect the OCX, and create an interop assembly for
it. Note the file it creates. This name is generated from the name of the
OCX's type library, and can be customized using a command line option for
tlbimp.
5) Go back into Web Matrix, and import the interop assembly into your project.
6) ASP.NET pages need to be in ASPCompat mode to use most OCXs, because
these components are not free threaded. Go into your page, and add an
attribute to the <%@ Page > directive at the top, like this:

<%@ Page AspCompat="true" %>

That's it - you should now be able to use this OCX on your page. You can't
drag and drop it onto the page, because it's not a web control, but you can
programmatically create one of these objects in your page code, such as in
Page_Load.

Thanks,
Shanku

[quoted text, click to view]
AddThis Social Bookmark Button