ComUtilities used without DLL registration?

521 views
Skip to first unread message

njo...@gmail.com

unread,
Jul 11, 2008, 5:08:49 PM7/11/08
to csEXWB
can the ComUtilities? DLL be used without registration? I can get
ClickOnce? to install the program using isolation, and open the web
browser on the PC, but after about 10 seconds the program bombs with:

EventType? : clr20r3 P1 : content.exe P2 : 1.0.0.0 P3 : 4877718c P4 :
csexwb P5 : 2.0.0.1 P6 : 48776f4a P7 : 792 P8 : 19 P9 :
system.invalidcastexception

mh

unread,
Jul 12, 2008, 5:58:28 AM7/12/08
to csEXWB
Hi,

On Jul 11, 2:08 pm, njo...@gmail.com wrote:
> can the ComUtilities? DLL be used without registration?

Yes. using Registeration-Free (isolation). But, since you are using
ClickOnce, you need to rebuild the dll (VC++) to include the manifest
file as described in the ControlRequirements page (http://
code.google.com/p/csexwb2/wiki/ControlRequirements) under Click Once
section.

> I can get
> ClickOnce? to install the program using isolation, and open the web
> browser on the PC, but after about 10 seconds the program bombs with:
> EventType? : clr20r3 P1 : cntent.exe P2 : 1.0.0.0 P3 : 4877718c P4 :
> csexwb P5 : 2.0.0.1 P6 : 48776f4a P7 : 792 P8 : 19 P9 :
> system.invalidcastexception

Regards,

MH

claire.allali

unread,
Jul 22, 2008, 10:35:10 AM7/22/08
to csEXWB
Hi,

I have a similar issue : IvalidCastException in cEXWB.cs, thrown by
the line :

m_csexwbCOMLib.HWNDInternetExplorerServer =
m_hWBServerHandle.ToInt32();

when I try to launch the AppControl.

It says it didn't succeed in casting the COM object
'ComUtilitiesLib.UtilManClass' to the interface
ComUtilitiesLib.IUtilMan, because the QueryInterface call returned
E_NOINTERFACE.

I used to do free COM registration with V1.0.0.7, and it worked fine.

Thank you in advance for your help,

Claire

claire.allali

unread,
Jul 23, 2008, 10:12:44 AM7/23/08
to csEXWB
I've just tested your new release, and still have the problem:
I registered ComUtilities.dll, then referenced it with isolated=true
and build the PageActivityMonitor project (release).
I closed visual.net, unregistered ComUtilities.dll and launched
PageActivityMonitor.exe : the program crash with no message.

Am I missing something ?

I tried to debug it, and just obtained this exception:

An unhandled exception of type 'System.InvalidCastException' occurred
in csExWB.dll
Message="Unable to cast COM object of type
'ComUtilitiesLib.UtilManClass'
to interface type 'ComUtilitiesLib.IUtilMan'. This operation failed
because
the QueryInterface call on the COM component for the interface with
IID
'{DD264321-7025-476C-8B7A-850E0B79DD41}' failed due to the following
error:
No such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE))."


Regards,

Claire

mh

unread,
Jul 25, 2008, 3:55:20 PM7/25/08
to csEXWB
Hi,

The exception that you are getting has nothing to do with the RegFree,
rather with the lack of a reference to Interop.ComUtilitiesLib.dll. If
you look at references for PageActivityMonitor project in solution
explorer, you will notice that there is a reference to the csExWB
control but no reference to Interop.ComUtilitiesLib.dll. if you try to
add a reference to Interop.ComUtilitiesLib.dll and attempt to build
the project while having set the isolated property of the
ComUtilitiesLib to true in the csExWB control, you will get an error
complainning that there is already a refernce to
Interop.ComUtilitiesLib.dll. And if you remove the reference from
PageActivityMonitor references section, build will be successful but
the InvalidCastException exception is thrown if you attempt to run
PageActivityMonitor as a RegFree app. To solve this problem, you can
create a new project outside of the csExWB solution. I have tested
this approach and it works. Here are the steps:

1) Register ComUtilities.dll, if you have not done already
2) Open csExWB.sln solution
3) In Solution Explorer, right click on the csExWB solution and select
Clean Solution
3) In csExWB project references (Solution Explorer) set
ComUtilitiesLib isolated property to true
4) From Solution Configuration, select Release
5) In Solution Explorer, right click on the csExWB and click on Build
menu item
6) From File menu select Close Solution
7) From File menu select New -> Project
8) Select a Windows Application type and name it RegFreeDemo (if you
choose a different name then you need to modify the sample manifest
file include further down the steps)
9) Select Release from the Solution explorer
10) Open up Form1 in design mode
11) Right click on the Toolbox (open it if not already opened) and
select Choose items
12) Click Browser in the Choose Toolbox items dialog
13) Find and select csExWB.dll from the Release folder of the csExWB
project
14) Select cExWB item from Toolbox and drop it on the Form1
15) Add two buttons (Go and Stop) and a Combox (Autocomplete for
allurls) and close the Form1 design window
16) Write the code, say
public Form1()
{
InitializeComponent();
this.button1.Click += new EventHandler(button1_Click);
this.button2.Click += new EventHandler(button2_Click);
this.cEXWB1.TitleChange += new
csExWB.TitleChangeEventHandler(cEXWB1_TitleChange);
}

void cEXWB1_TitleChange(object sender,
csExWB.TitleChangeEventArgs e)
{
this.Text = e.title;
}

void button2_Click(object sender, EventArgs e)
{
this.cEXWB1.Stop();
}

void button1_Click(object sender, EventArgs e)
{
this.cEXWB1.Navigate(this.comboBox1.Text);
}

17) In Solution Explorer, right click on References and select Add
Refernece
18) Find and select Interop.ComUtilitiesLib.dll from the Release
folder of the csExWB project
19) Build RegFreeDemo and run it to make sure it works
20) Close solution
21) From Release folder of the csExWB project, copy
ComUtilities.dll and Native.csExWB.manifest files to
Release folder of RegFreeDemo application
22) Now all is left is to setup a manifest file for RegFreeDemo.exe
22) In the Release folder of RegFreeDemo create a new text file and
rename it to RegFreeDemo.exe.manifest (no .txt extension)
23) Add the following to the RegFreeDemo.exe.manifest file

<?xml version="1.0" encoding="utf-8"?>
<assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1
assembly.adaptive.xsd" manifestVersion="1.0" xmlns:asmv1="urn:schemas-
microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2"
xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns="urn:schemas-
microsoft-com:asm.v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance">
<assemblyIdentity name="RegFreeDemo.exe" version="1.0.0.0"
processorArchitecture="x86" type="win32" />
<dependency>
<dependentAssembly asmv2:dependencyType="install"
asmv2:codebase="Native.csExWB.manifest" asmv2:size="1682">
<assemblyIdentity name="Native.csExWB" version="2.0.0.2"
processorArchitecture="x86" type="win32" />
<hash xmlns="urn:schemas-microsoft-com:asm.v2">
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-
com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/
xmldsig#sha1" />
<dsig:DigestValue>wf0AZNCkgMrFLvy3DI7mbqrm9/o=</
dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>
</assembly>

24) Save RegFreeDemo.exe.manifest file
25) Unregister ComUtilities.dll. regsvr32.exe /U whateverfolder
\ComUtilities.dll
26) Now run RegFreeDemo.exe. you should get no exceptions.

Regards,

MH
> > > MH- Hide quoted text -
>
> - Show quoted text -

claire.allali

unread,
Jul 30, 2008, 8:45:20 AM7/30/08
to csEXWB
Thank you once again !

I've tested your RegFreeDemo project, and it worked great :)

I tried this approach, and I did not have to create the manifest file
and copy dlls myself:

1)
...
17) In Solution Explorer, right click on References and select Add >
Reference
18) Find and select Native.csExWB.manifest from the Release folder of
the csExWB project
19) Build RegFreeDemo and run it to make sure it works
20) Close solution
21) Unregister ComUtilities.dll. regsvr32.exe /U whateverfolder
ComUtilities.dll
22) Now run RegFreeDemo.exe. you should get no exception

Regards,

Claire

Koen Zwikstra

unread,
Aug 4, 2008, 7:12:17 AM8/4/08
to cse...@googlegroups.com
MH,

I've been trying to create a registration free ComUtilities. I have followed all the instructions to create the RegFreeDemo and it seems to work okay. Except when the first page you navigate to contains a Silverlight application.

If I run RegFreeDemo and navigate to http://silverlightspy.com/silverlight/startpage2 the following exception occurs:


Unable to cast COM object of type 'ComUtilitiesLib.UtilManClass' to interface type 'ComUtilitiesLib.IUtilMan'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{DD264321-7025-476C-8B7A-850E0B79DD41}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

The strange thing is that this only occurs when the silverlight page is the first page you navigate to. If you navigate to http://www.google.com first and then to the silverlight page, everything seems to be working fine.

Navigating to the silverlight page immediately also works when the ComUtilities dll is registered.

Do you have any clue what might causing this?

Thanks,
Koen

Koen Zwikstra

unread,
Aug 4, 2008, 7:17:00 AM8/4/08
to cse...@googlegroups.com
btw: that silverlight page link should be: http://silverlightspy.com/silverlightspy/startpage2/

mh

unread,
Aug 4, 2008, 2:29:31 PM8/4/08
to csEXWB
Koen,

Calling NavToBlank() in the form_load event should resolve the issue.

Regards,

MH

On Aug 4, 3:17 am, Koen Zwikstra <k...@defred.demon.nl> wrote:
> btw: that silverlight page link should be:http://silverlightspy.com/silverlightspy/startpage2/
>
>
>
> Koen Zwikstra wrote:
> > MH,
>
> > I've been trying to create a registration free ComUtilities. I have
> > followed all the instructions to create the RegFreeDemo and it seems
> > to work okay. Except when the first page you navigate to contains a
> > Silverlight application.
>
> > If I run RegFreeDemo and navigate to
> >http://silverlightspy.com/silverlight/startpage2the following
> > exception occurs:
>
> > Unable to cast COM object of type 'ComUtilitiesLib.UtilManClass' to
> > interface type 'ComUtilitiesLib.IUtilMan'. This operation failed
> > because the QueryInterface call on the COM component for the interface
> > with IID '{DD264321-7025-476C-8B7A-850E0B79DD41}' failed due to the
> > following error: No such interface supported (Exception from HRESULT:
> > 0x80004002 (E_NOINTERFACE)).
>
> > The strange thing is that this only occurs when the silverlight page
> > is the first page you navigate to. If you navigate to
> >http://www.google.comfirst and then to the silverlight page,
> ...
>
> read more »- Hide quoted text -

Koen Zwikstra

unread,
Aug 4, 2008, 2:48:04 PM8/4/08
to cse...@googlegroups.com
MH,

Unfortunately, that doesn't resolve the issue. I've tried the Shown event as well to no avail.

However, it does seem to be a timing issue. If I wait a number of seconds after the form has loaded, the application does not crash.

Is there any way to detect when its safe to start using the csexwb browser?

Thanks

mh

unread,
Aug 4, 2008, 4:26:31 PM8/4/08
to csEXWB
When IEServerHwnd property returns a valid value (not IntPtr.Zero)
indicating that we have a valid "Internet Explorer_Server" HWND.

Regards,

MH
> >>>http://www.google.comfirstand then to the silverlight page,

Koen Zwikstra

unread,
Aug 4, 2008, 5:26:18 PM8/4/08
to cse...@googlegroups.com
Okay, that seems to work. I now have a csexwb control that uses a registration-free ComUtilities.

However, another problem arises; I use the DownloadRequestAsynch and DownloadRequestSynch events to perform my own downloads of Silverlight XAP packages. The custom download seems to work fine, but when I give the downloaded bytes back to the webbrowser control the Silverlight plugin does not seem to be loaded at all. There's no UI and there are no errors either.

The moment I register ComUtilities, everything works fine. Easily reproducable by adding custom download event handlers to the RegFreeDemo app and navigating the browser control to http://silverlightspy.com/silverlightspy/startpage2/.

Apologies for the nagging, you've been a great help so far ! :-)

Koen

Miamidot

unread,
Aug 11, 2008, 1:42:02 AM8/11/08
to csEXWB
I need some education on this issue.

I downloaded and unzipped csExWBv2.0.0.2_Includes_ComUtilities.
I opened ComUtilities, rebuilt it with no errors.
I opened the csExWBv2 solution, pointed ComUtilities.dll reference to
the right place and rebuilt with no errors.

I did not bother to register ComUtilities.dll at all.

I ran the debug. I surfed the web, read the news and downloaded a few
files.
I did the same with the release build.

When am I supposed to encounter and error due my not having registered
ComUtilities.dll ?

I am running VS2005 on Vista.

What did I do wrong?

Is it possible that I had tried running csExWB some months ago I had
downloaded from codeguru. I don't remember having registered any com
utils for that one too.

Any idea?

mh

unread,
Aug 11, 2008, 6:23:52 AM8/11/08
to csEXWB
Hi,

By default, VC++ is set to register the output file. Project (menu) ->
ComUtilities Properties... (menu) -> ComUtilities Property Pages ->
Linker -> General -> Register Output.

Regards,

MH

Koen Zwikstra

unread,
Aug 14, 2008, 2:00:56 PM8/14/08
to cse...@googlegroups.com
Silverlight applications do not work in the registration-free ComUtilities scenario. Does anyone have an idea what might be causing this?

See also my message below,

Thanks in advance,

Koen

mh

unread,
Aug 28, 2008, 9:05:07 AM8/28/08
to csEXWB
Koen,

Sorry, took me a while to track down the cause. The problem was with
the IManagedProtocolSink.ManagedAppxxxxxx methods located in cEXWB.cs
file. It seems that under Reg-Free COM, any attempt to convert
IDispatch (param: sink) of ManagedAppBridge instance to
ComUtilitiesLib.IManagedAppBridge interface fails (returns null). I
have tested a workaround using InvokeMember and it seems to work under
Reg-Free COM without any problems.
Here is what you need to do:

1) In cEXWB.cs file, under "#region IManagedProtocolSink Members -
Asynchronous pluggable protocols (APP), via ComUtilitiesLib COM
library";

A) Add
/// <summary>
/// Helper method, called from
/// ManagedAppDownloadCompletedAsynch
/// CustomAppDownloadCompleted
/// </summary>
/// <param name="data">A reference to a variant wrapping a
byte array</param>
/// <param name="len">Length of byte array contained in data</
param>
/// <param name="Url"></param>
/// <param name="mimeType"></param>
/// <param name="sink">Object to invoke</param>
private void SendInvoke(ref object data, int len, string Url,
string mimeType, object sink)
{
try
{
object[] invkparam = new object[] { Url, mimeType,
data, len };
sink.GetType().InvokeMember("[DispID=1]",
BindingFlags.InvokeMethod, null, sink, invkparam);

}
catch (Exception)
{

throw;
}
}

B) Replace ManagedAppDownloadCompletedAsynch with
/// <summary>
/// Called from DownloadCompleted method of
DownloadRequestEventArgs
/// event argument passed to client via ProtocolHandlerOnStart
event
/// </summary>
/// <param name="data">Byte array representing downloaded data</
param>
/// <param name="redirectedUrl">Redirected url or the original</
param>
/// <param name="mimeType">Mime type of downloaded data</param>
/// <param name="sink">IManagedAppBridge instance</param>
void IManagedProtocolSink.ManagedAppDownloadCompletedAsynch(byte[]
data, string Url, string mimeType, object sink)
{
if (sink != null)
{
//Convert IDispatch of ManagedAppBridge instance to
ComUtilitiesLib.IManagedAppBridge interface
ComUtilitiesLib.IManagedAppBridge appsink = sink as
ComUtilitiesLib.IManagedAppBridge;
if (appsink != null)
{
object APPSinkData = data;
appsink.DownloadCompleteManaged(Url, mimeType, ref
APPSinkData, data.Length);
}
else
{
//Use invoke - Reg-Free COM
//"[DispID=1]"
try
{
object APPSinkData = data;
SendInvoke(ref APPSinkData, data.Length, Url,
mimeType, sink);
}
catch (Exception)
{

throw;
}
}
}
}

C) Replace ManagedAppDownloadCompletedAsynchNeedFileName with
void
IManagedProtocolSink.ManagedAppDownloadCompletedAsynchNeedFileName(string
Url, string mimeType, object sink, string CacheFileName)
{
if (sink != null)
{
ComUtilitiesLib.IManagedAppBridge appsink = sink as
ComUtilitiesLib.IManagedAppBridge;
if (appsink != null)
{
appsink.DownloadCompleteManagedCache(Url, mimeType,
CacheFileName);
}
else
{
//"[DispID=11]"
try
{
object[] invkparam = new object[] { Url, mimeType,
CacheFileName };
sink.GetType().InvokeMember("[DispID=11]",
BindingFlags.InvokeMethod, null, sink, invkparam);

}
catch (Exception)
{

throw;
}
}
}
}

D) Replace ManagedAppAbortDownload with
/// <summary>
/// Called from CancelDownloadRequest method of
DownloadRequestEventArgs
/// event argument passed to client via ProtocolHandlerOnStart
event
/// </summary>
/// <param name="Inet_Error_Code">One of Inet_Error_xxxx errors.
WinInetErrors enum can be used.</param>
/// <param name="sink">IManagedAppBridge instance</param>
void IManagedProtocolSink.ManagedAppAbortDownload(int
Inet_Error_Code, object sink)
{
if (sink != null)
{
ComUtilitiesLib.IManagedAppBridge appsink = sink as
ComUtilitiesLib.IManagedAppBridge;
if (appsink != null)
appsink.DownloadAbortManaged(Inet_Error_Code);
}
else
{
//"[DispID=2]"
try
{
object[] invkparam = new object[] { Inet_Error_Code };
sink.GetType().InvokeMember("[DispID=2]",
BindingFlags.InvokeMethod, null, sink, invkparam);
}
catch (Exception)
{

throw;
}
}
}

2) In cEXWB.cs file, under "#region ICustomProtocolSink Members";

A) Replace CustomAppDownloadCompleted with
void ICustomProtocolSink.CustomAppDownloadCompleted(byte[] data,
string Url, string mimeType, object sink)
{
if (sink != null)
{
ComUtilitiesLib.ICustManageApp custapp = sink as
ComUtilitiesLib.ICustManageApp;
if (custapp != null)
{
object APPSinkData = data;
custapp.DownloadCompleteCustomApp(Url, mimeType, ref
APPSinkData, data.Length);
}
else
{
try
{
//"[DispID=1]"
object APPSinkData = data;
SendInvoke(ref APPSinkData, data.Length, Url,
mimeType, sink);
}
catch (Exception)
{
throw;
}
}

}
}

B) Replace CustomAppAbortDownload with
void ICustomProtocolSink.CustomAppAbortDownload(int
Inet_Error_Code, object sink)
{
if (sink != null)
{
ComUtilitiesLib.ICustManageApp custapp = sink as
ComUtilitiesLib.ICustManageApp;
if (custapp != null)
custapp.DownloadAbortCustomApp(Inet_Error_Code);
}
else
{
try
{
object[] invkparam = new object[] { Inet_Error_Code };
sink.GetType().InvokeMember("[DispID=2]",
BindingFlags.InvokeMethod, null, sink, invkparam);

}
catch (Exception)
{
throw;
}
}
}

Regards,

MH
> >>>>>>http://www.google.comfirstandthen to the silverlight page,

Koen Zwikstra

unread,
Aug 31, 2008, 2:35:51 PM8/31/08
to cse...@googlegroups.com
MH,

Works like a charm! Brilliant as always, thanks for the solution.
Reply all
Reply to author
Forward
0 new messages