Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CAB files still work in .NET?

150 views
Skip to first unread message

Havic Ploccin

unread,
Apr 30, 2003, 5:10:42 PM4/30/03
to
I have a legacy app that uses a CAB file download mechanism to run client
side ActiveX controls.

1. Is this Internet COmponent Download mechanism still supported in .NET?
2. Will it be supported if I mix .NET asemblies with ActiveX controls in the
CAB file?
3. What does it mean for the .NET framework to have the .NET assemblies
delivered to the "Downloaded
Program Files" cache?
4. Can I have the ActiveX controls call into the .NET assemlies without
registering the latter in the GAC (i.e. CAB download mechanism will not
register anythingin the GAC)?

Are there any special issues I must be concerned about while mixing ActiveX
controls and .NET asemblies in a CAB file?

Anybody from Microsoft can answer this?

Thanks for any help!!!!


Reid Wilkes

unread,
May 1, 2003, 3:02:13 AM5/1/03
to
Answers inline...

-Reid [MS]

"Havic Ploccin" <no.email@please> wrote in message
news:#5$DDy1DD...@TK2MSFTNGP11.phx.gbl...


> I have a legacy app that uses a CAB file download mechanism to run client
> side ActiveX controls.
>
> 1. Is this Internet COmponent Download mechanism still supported in .NET?

REID - Yes.

> 2. Will it be supported if I mix .NET asemblies with ActiveX controls in
the
> CAB file?

REID - This is possible, yes.

> 3. What does it mean for the .NET framework to have the .NET assemblies
> delivered to the "Downloaded
> Program Files" cache?

REID - This location is a temporary place the runtime uses to store
assemblies that have been downloaded until they are actually loaded. If you
use CAB file deployment the mechanism in the CLR and CLR MIME filter which
puts files there is bypassed, so it's not an issue in that scenario.

> 4. Can I have the ActiveX controls call into the .NET assemlies without
> registering the latter in the GAC (i.e. CAB download mechanism will not
> register anythingin the GAC)?

REID - Short answer: No. The basic scenario is to put the .NET assembly
in the GAC and regasm it (calling both utilities with commands in the .inf
file).
Long answer: Maybe. Internally, when the CLR hosts managed controls in
the browser in standard scenario (OBJECT tag with CLASSID attribute pointing
to assembly), we actually create a CCW around the managed control and hand
that CCW to IE. So to IE, every control, managed or not, is ActiveX. This
means that it's probably possible to pass a reference to one of the managed
objects to one of your ActiveX objects in the JScript on the HTML page. Of
course, in this scenario you are not packaging the managed controls in CAB
file, but you do get the interaction between the managed object and COM
object without registering in GAC.

> Are there any special issues I must be concerned about while mixing
ActiveX
> controls and .NET asemblies in a CAB file?

REID - I can't think of anything that I didn't touch on above. It's
fairly straight forward. If you need examples please repost, I'll see if I
can find something at work tomorrow and send it your way.

> Anybody from Microsoft can answer this?

REID - hope this helps.

> Thanks for any help!!!!
>
>


Havic Ploccin

unread,
May 1, 2003, 3:59:58 PM5/1/03
to
Reid,
Thank you very much. This is excellent information. I would really
appreciate it if you would post a sample to this newsgroup with a CAB file
that has a mix of ActiveX and .NET which interoperate on the web page.
Specifically, this is what I am trying to do:
A. Have a CAB delivery mechanism for my legacy ActiveX controls and new .NET
assemblies.
B. I need the .NET assemblies because the client will need to communicate
with a .NET web service on another server.
C. The legacy ActiveX controls will extract data from the .NET objects at
runtime and display the result.

Also, could you please elaborate on the following points (would be great if
you also incorporated this in your sample):

- In item 3 below you said "If you use CAB file deployment the mechanism in


the CLR and CLR MIME filter which puts files there is bypassed, so it's not

an issue in that scenario.". What does this mean? Are you saying that .NET
assemblies will NOT go into the 'Downloaded Program Files" folder?
- In item 4, your explanation of the automaticCCW wrapper in IE makes sense.
How would my code be able to produce this automatic CCW wapper like IE?
- If I cannot, the only option is regasm right?
- If so, would you also show me how to add the entries in the .INF file that
would automatically run regasm on the .NET assembly after being downloaded
using the CAB file?
- Lastly, if the .NET class wants to talk to the ActiveX object, is the RCW
creation automatic, or would that have to be facilitated via the CAB file
mechsnism itself (by running something similar to regasm)?

Thanks again!!

This probably means I dont have to run regasm then?
"Reid Wilkes" <re...@online.microsoft.com> wrote in message
news:#4FgV#6DDHA...@TK2MSFTNGP12.phx.gbl...

Reid Wilkes [MS]

unread,
May 1, 2003, 4:44:28 PM5/1/03
to
Some more inline comments, and then the .INF file is posted at the end.

-Reid [MS]

"Havic Ploccin" <no.email@please> wrote in message

news:ugDFLvBE...@TK2MSFTNGP10.phx.gbl...


> Reid,
> Thank you very much. This is excellent information. I would really
> appreciate it if you would post a sample to this newsgroup with a CAB file
> that has a mix of ActiveX and .NET which interoperate on the web page.
> Specifically, this is what I am trying to do:
> A. Have a CAB delivery mechanism for my legacy ActiveX controls and new
.NET
> assemblies.
> B. I need the .NET assemblies because the client will need to communicate
> with a .NET web service on another server.
> C. The legacy ActiveX controls will extract data from the .NET objects at
> runtime and display the result.
>
> Also, could you please elaborate on the following points (would be great
if
> you also incorporated this in your sample):
>
> - In item 3 below you said "If you use CAB file deployment the mechanism
in
> the CLR and CLR MIME filter which puts files there is bypassed, so it's
not
> an issue in that scenario.". What does this mean? Are you saying that .NET
> assemblies will NOT go into the 'Downloaded Program Files" folder?

REID - exactly. As long as we're talking about the same thing here.
There are 2 caches used: WININET cache (aka Temporary Internet Files), and
the Fusion Download cache (which I think you are calling "Downloaded Program
Files"). The Fusion Download cache will not be used if you deploy with CAB
files because you are specifying explicitly where you want the assembly to
go in the inf file.

> - In item 4, your explanation of the automaticCCW wrapper in IE makes
sense.
> How would my code be able to produce this automatic CCW wapper like IE?
> - If I cannot, the only option is regasm right?

REID - You can't produce the CCW because there would be no way to hand
that CCW back to IE. Essentially you would have to write your own protocol
handler or MIME filter... not a trivial task. Sticking with CAB files, you
are going to have to regasm the assemblies.

> - If so, would you also show me how to add the entries in the .INF file
that
> would automatically run regasm on the .NET assembly after being
downloaded
> using the CAB file?

REID - the INF file snippet below demonstrates this.

> - Lastly, if the .NET class wants to talk to the ActiveX object, is the
RCW
> creation automatic, or would that have to be facilitated via the CAB file
> mechsnism itself (by running something similar to regasm)?
>

REID - Neither is really correct. The RCW has to be created with TLBIMP,
and it has to be done before you compile the managed code so that you can
compile with a reference to the TLBIMP generated metadata assembly. This
also means you have to deploy the metadata assembly and install in the GAC
through the CAB file, if you want the managed object to be able to call the
native objects.


========Example INF File - explanation===============
description of elements:
mg.dll - managed assembly.
com.dll - COM DLL (not ActiveX -- this does not expose UI on page)
ctlMetadata.dll - tlbimp generated assembly for com.dll
=========ExampleINF File=====================
[Setup Hooks]
hook1=hook1
hook2=hook2
hook3=hook3
hook4=hook4


[hook1]
run=regasm.exe %EXTRACT_DIR%\mg.dll

[hook2]
run=gacutil.exe /i %EXTRACT_DIR%\mg.dll

[hook3]
run=gacutil.exe /i %EXTRACT_DIR%\ctlMetadata.dll

[hook4]
run=regsvr32 /s c:\com.dll


[Version]
; This section is required for compatibility on both Windows 95 and Windows
NT.
Signature="$CHICAGO$"
AdvancedInf=2.0
========Example HTML Page - explanation===================
What we do here is load the managed object (Winform control) via CLASSID
because it has been registered in the GAC and regasm'ed. The managed object
exposes a method called CallCOM(). This method instantiates the COM object
(it can do that because of ctlMetadata.dll), and calls a method on it.
========Example HTML Page==============================
<HTML>
<BODY>
<p>
<B>Downloads a control that creates a file on disk</B>
</p>

<p><OBJECT ID="myserver"
CLASSID="CLSID:03B0555C-34F3-4fa4-9B11-E03C20E6154A"
CODEBASE="mg_umg.CAB#version=0,0,0,0"
width=100%
height=50>
</OBJECT>


<B>This is the JavaScript Test</B>
<INPUT NAME="JAnswer1" Size="100">
<INPUT NAME="JAnswer2" Size="100">

<BODY onLoad="Runall()";>


<SCRIPT LANGUAGE="JavaScript">

function JClick1(){
JAnswer1.value = myserver.TestLog;
JAnswer2.value = myserver.callCOM();
if ((JAnswer1.value == 'Control successfully createdControl TEXT:
Successfully painted control') && (JAnswer2.value == 25))
self.status='Pass';
else {
self.status='Fail';
}
}

function Runall(){
setTimeout("JClick1()", 3000);
}

</SCRIPT>
</BODY>
</HTML>


Havic Ploccin

unread,
May 1, 2003, 5:54:41 PM5/1/03
to
Reid,
Thanks agin. I think this will give me a nice base to build with. One
thing though. I dont have an "extract" directory and explictly want the DLLs
and asemblies to be downloaed to the default CAB download destination (i.e.
<sys_drive>:\<sys_dir>\Downloaded Program Files, which I think you are
calling the Fusion cache). My way of registering COM objects is to have an
[Add.Code] secion with the list of DLLs, and for each dll, have another
section like this (which is equivalent to your hook 4, I think):

[MyCOMServer.dll]
file-win32-x86=thiscab
FileVersion=1,0,0,0
RegisterServer=yes


In this situation, how do I modify the other hooks below to ensure the
assemblies get registered in that same location as the other COM server
DLLs?

Is "%EXTRACT_DIR%" automatically set to "<sys_drive>:\<sys_dir>\Downloaded
Program Files" somehow unless you override it?

Thanks for your help thus far!

"Reid Wilkes [MS]" <re...@online.microsoft.com> wrote in message
news:OLOl2JCE...@TK2MSFTNGP10.phx.gbl...

Reid Wilkes [MS]

unread,
May 1, 2003, 7:03:13 PM5/1/03
to
Ok, so I misunderstood. The Download Program Files folder is not the same
as the fusion cache. Completely different concepts. Now I'm on the same page
as you. As to the answer for your question: the managed assemblies will not
be in the Download Program Files folder. You can't do this. They HAVE to be
in the GAC for it to work. By doing the GACUTIL in the inf file, they are
put directly into the GAC.

-Reid [MS]

"Havic Ploccin" <no.email@please> wrote in message

news:uCqGRvCE...@TK2MSFTNGP11.phx.gbl...

Havic Ploccin

unread,
May 2, 2003, 9:42:23 AM5/2/03
to
Thank you.

"Reid Wilkes [MS]" <re...@online.microsoft.com> wrote in message

news:#PUKZXDE...@TK2MSFTNGP12.phx.gbl...

Havic Ploccin

unread,
May 8, 2003, 3:33:18 PM5/8/03
to
Reid,
I did some testing and what I found is that the method you have
specified (using "Setup Hooks") will not work for me, because when you
uninstall the CAB file-delivered components (rt-click on your component in
<sys_drive>:\<sys_dir>\Downloaded Program Files" and select "Remove"), it
will ONLY cleanup the registry if you go though the Add.Code method (where
you specify "RegisterServer=yes") but not if you use the "Setup Hooks"
method. I cannot afford to leave registry remnants behind on a user's
system. Secondly, it is also not clear how to ensure we store the dependent
information in the INF file using your method, i.e. I must be able to
deliver every single MFC, VB or other dependent Microsoft re-distributable
components with my CAB delivery, in case the user has a virgin system. Using
the Add.Code method, it is easy.

So I have implemented the Add.Code method, and here is the INF file
(currently simply registering OCX and .NET components):
----------------------------------------------------------------------------
[Version]
Signature="$CHICAGO$"
AdvancedINF=2.0

[Add.Code]
Project1.ocx=Project1.ocx --------------------> simple VB 6 OCX
ClassLibrary1.dll=ClassLibrary1.dll --------------------> .NET assembly
MFC42.DLL=MFC42.DLL
MSVCP60.DLL=MSVCP60.DLL
MSVCRT.DLL=MSVCRT.DLL
ATL.DLL=ATL.DLL
MSVBVM60.DLL=MSVBVM60.DLL

[Project1.ocx]
file-win32-x86=thiscab
FileVersion=1,0,0,0
Clsid={1279B6FF-61EF-43B3-A744-1E624ABCFFB0} ----> replace with your
own GUID for testing
RegisterServer=yes

[ClassLibrary1.dll]
file-win32-x86=thiscab
FileVersion=1,0,0,1 ----------> hardcoded in my assembly
RegisterServer=no
hook=DOTNET_INSTALLER

[MFC42.DLL]
FileVersion=6,0,8168,0
hook=MFC42_INSTALLER

[MSVCP60.DLL]
file-win32-x86=thiscab
FileVersion=6,0,8972,0
RegisterServer=no

[MSVCRT.DLL]
FileVersion=6,0,8168,0
hook=MFC42_INSTALLER

[ATL.DLL]
FileVersion=3,0,8449,0
hook=ATL_INSTALLER

[MSVBVM60.DLL]
FileVersion=6,0,89,64
hook=MSVBVM60_INSTALLER

[MFC42_INSTALLER]
file-win32-x86=http://activex.microsoft.com/controls/vc/mfc42.cab
run=%EXTRACT_DIR%\mfc42.exe

[MSVBVM60_INSTALLER]
file-win32-x86=http://activex.microsoft.com/controls/vb6/MSVBVM60.cab
InfFile=MSVBVM60.inf

[ATL_INSTALLER]
file-win32-x86=http://activex.microsoft.com/controls/vc/atl.cab
run=%EXTRACT_DIR%\atl.exe

[DOTNET_INSTALLER]
run=regasm.exe %EXTRACT_DIR%\ClassLibrary1.dll
----------------------------------------------------------------------------
-----

The problem is that the last line seem to be completely ignored, i.e.
regasm.exe did not work. It would not work even if I changed it to
"%OBJECT_DIR%". Finally I figured out that "regasm" is not in the path!! If
I open a regular command window (not the VS .NET 2003 command window,
because that would imply all my clients had to have VS.NET installed) to run
regasm.exe, the cmd window errors out because it is not in the path.

PROBLEM 1:

To deliver .NET assemblies via CAB files on which I need to run regasm, all
clients must have the framework directory in their path.

PROBLEM 2:

gacutil.exe is not even a .NET Framework component, but a part of VS.NET
SDK, which makes the problem even worse (for the average CAB file client) if
I need to install the assembly in the GAC.

PROBLEM 3:

Even when I added the path to regasm to my system path, the last command was
silently ignored, so my .NET component got downloaded to
"<sys_drive>:\<sys_dir>\Downloaded Program Files", but was not registered
using regasm.


Can you please let me know how we can resolve these issues? This is very
important for me. Thanks.

Havic

"Reid Wilkes [MS]" <re...@online.microsoft.com> wrote in message

news:#PUKZXDE...@TK2MSFTNGP12.phx.gbl...

0 new messages