473,692 Members | 2,196 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can create object using C++ CoCreateInstanc e, but not using C# Activator.Creat eInstance

Hello everyone,

I apologize for the cross and re-post, but I am still searching for an
answer.

Why can C++ can create this object, but C# can't?

I am trying to create an instance of the default FTP asynchronous pluggable
protocol adaptor, so I can analyse the traffic between urlmon.dll (IE) and
the FTP server. The language I am attempting to use is C#.

The CLSID for the adaptor (as referenced in the protocol registry key) is
{79eac9e3-baf9-11ce-8c82-00aa004ba90b} and is stored as CLSID_FtpProtoc ol.

If I use the following unmanaged C++ code, I can create an instance of the
filter.

HRESULT result;
LPUNKNOWN _pUnk = NULL;
CoInitialize( NULL);
result = CoCreateInstanc e( CLSID_FtpProtoc ol,
NULL,
CLSCTX_INPROC_S ERVER,
IID_IInternetPr otocol,
(LPVOID*)&_pUnk );

If I use the following C# code, I receive an error. (OutOfMemoryExc eption)

Guid IID_IInternetPr otocolInfo = new
Guid("{79eac9e3-baf9-11ce-8c82-00aa004ba90b}") ;
objType = Type.GetTypeFro mCLSID(IID_IInt ernetProtocolIn fo);
Activator.Creat eInstance(objTy pe);

Any thoughts would be greatly appreciated.

Thanks,
Brian.


Nov 15 '05 #1
15 12802
Brian,

If you are trying to access the asyncronous pluggable protocol adaptor,
you shouldn't be creating it directly, but rather, you should be using the
IMoniker interface.

However, that doesn't mean that one ^can't^ create it directly, as it
should just be another COM object. It could be that there is something in
the constructor of the class that detects some sort of context (just a
guess).

As a workaround, you can have unmanaged code that creates the object,
and then passes the pointer to managed code.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Brian Rogers" <no**@none.co m> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hello everyone,

I apologize for the cross and re-post, but I am still searching for an
answer.

Why can C++ can create this object, but C# can't?

I am trying to create an instance of the default FTP asynchronous pluggable protocol adaptor, so I can analyse the traffic between urlmon.dll (IE) and
the FTP server. The language I am attempting to use is C#.

The CLSID for the adaptor (as referenced in the protocol registry key) is
{79eac9e3-baf9-11ce-8c82-00aa004ba90b} and is stored as CLSID_FtpProtoc ol.

If I use the following unmanaged C++ code, I can create an instance of the
filter.

HRESULT result;
LPUNKNOWN _pUnk = NULL;
CoInitialize( NULL);
result = CoCreateInstanc e( CLSID_FtpProtoc ol,
NULL,
CLSCTX_INPROC_S ERVER,
IID_IInternetPr otocol,
(LPVOID*)&_pUnk );

If I use the following C# code, I receive an error. (OutOfMemoryExc eption)

Guid IID_IInternetPr otocolInfo = new
Guid("{79eac9e3-baf9-11ce-8c82-00aa004ba90b}") ;
objType = Type.GetTypeFro mCLSID(IID_IInt ernetProtocolIn fo);
Activator.Creat eInstance(objTy pe);

Any thoughts would be greatly appreciated.

Thanks,
Brian.

Nov 15 '05 #2
Hi Nicholas,

I appreciate the feedback.

The objective is to place a wrapper around the protocol adapter, so I can
reverse engineer the data flow in both directions. I want to analyse the
data flow between IE and the FTP protocol handler.

I actually have no idea how the IMoniker interface comes into play. I
believe the handler was supposed to support the IInternetProtoc ol and
IInternetProtoc olRoot interfaces amongst others. Currently, I can't even
create the filter to bind it to IUnknown.

In the end, I want to create a custom FTP Protocol handler in C#. My C++ is
not good enough to create and expose an unmanaged factory class, so that was
not an option for me.

Thanks,
B.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:uR******** ******@TK2MSFTN GP10.phx.gbl...
Brian,

If you are trying to access the asyncronous pluggable protocol adaptor, you shouldn't be creating it directly, but rather, you should be using the
IMoniker interface.

However, that doesn't mean that one ^can't^ create it directly, as it
should just be another COM object. It could be that there is something in
the constructor of the class that detects some sort of context (just a
guess).

As a workaround, you can have unmanaged code that creates the object,
and then passes the pointer to managed code.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Brian Rogers" <no**@none.co m> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hello everyone,

I apologize for the cross and re-post, but I am still searching for an
answer.

Why can C++ can create this object, but C# can't?

I am trying to create an instance of the default FTP asynchronous

pluggable
protocol adaptor, so I can analyse the traffic between urlmon.dll (IE) and the FTP server. The language I am attempting to use is C#.

The CLSID for the adaptor (as referenced in the protocol registry key) is {79eac9e3-baf9-11ce-8c82-00aa004ba90b} and is stored as CLSID_FtpProtoc ol.
If I use the following unmanaged C++ code, I can create an instance of the filter.

HRESULT result;
LPUNKNOWN _pUnk = NULL;
CoInitialize( NULL);
result = CoCreateInstanc e( CLSID_FtpProtoc ol,
NULL,
CLSCTX_INPROC_S ERVER,
IID_IInternetPr otocol,
(LPVOID*)&_pUnk );

If I use the following C# code, I receive an error. (OutOfMemoryExc eption)
Guid IID_IInternetPr otocolInfo = new
Guid("{79eac9e3-baf9-11ce-8c82-00aa004ba90b}") ;
objType = Type.GetTypeFro mCLSID(IID_IInt ernetProtocolIn fo);
Activator.Creat eInstance(objTy pe);

Any thoughts would be greatly appreciated.

Thanks,
Brian.


Nov 15 '05 #3
Brian,
If I use the following unmanaged C++ code, I can create an instance of the
filter.

HRESULT result;
LPUNKNOWN _pUnk = NULL;
CoInitialize ( NULL);
result = CoCreateInstanc e( CLSID_FtpProtoc ol,
NULL,
CLSCTX_INPROC_S ERVER,
IID_IInternetPr otocol,
(LPVOID*)&_pUnk );


If I replace IID_IInternetPr otocol with IID_IUnknown, I get an access
violation exception. Unless I'm missing something, that looks like a
bug. I suspect that's why you get the exception in managed code.

The only workaround I can suggest is that you call CoCreateInstanc e
through P/Invoke.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #4
Brian,

It would be much easier to implement a pluggable protocol handler in
C++. You can create an ATL project that will do all of the COM plumbing for
you. Once you have that, all you should have to worry about is the
implementation of the interface (along with the registration).

However, I don't know if you can register your own FTP handler. I think
that for protocols like HTTP and FTP, the COM Moniker framework hard-codes
the protocol handlers.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Brian Rogers" <no**@none.co m> wrote in message
news:ed******** ******@TK2MSFTN GP09.phx.gbl...
Hi Nicholas,

I appreciate the feedback.

The objective is to place a wrapper around the protocol adapter, so I can
reverse engineer the data flow in both directions. I want to analyse the
data flow between IE and the FTP protocol handler.

I actually have no idea how the IMoniker interface comes into play. I
believe the handler was supposed to support the IInternetProtoc ol and
IInternetProtoc olRoot interfaces amongst others. Currently, I can't even
create the filter to bind it to IUnknown.

In the end, I want to create a custom FTP Protocol handler in C#. My C++ is not good enough to create and expose an unmanaged factory class, so that was not an option for me.

Thanks,
B.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in message news:uR******** ******@TK2MSFTN GP10.phx.gbl...
Brian,

If you are trying to access the asyncronous pluggable protocol

adaptor,
you shouldn't be creating it directly, but rather, you should be using the
IMoniker interface.

However, that doesn't mean that one ^can't^ create it directly, as it should just be another COM object. It could be that there is something in the constructor of the class that detects some sort of context (just a
guess).

As a workaround, you can have unmanaged code that creates the object, and then passes the pointer to managed code.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Brian Rogers" <no**@none.co m> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hello everyone,

I apologize for the cross and re-post, but I am still searching for an
answer.

Why can C++ can create this object, but C# can't?

I am trying to create an instance of the default FTP asynchronous

pluggable
protocol adaptor, so I can analyse the traffic between urlmon.dll (IE)

and the FTP server. The language I am attempting to use is C#.

The CLSID for the adaptor (as referenced in the protocol registry key) is {79eac9e3-baf9-11ce-8c82-00aa004ba90b} and is stored as CLSID_FtpProtoc ol.
If I use the following unmanaged C++ code, I can create an instance of the filter.

HRESULT result;
LPUNKNOWN _pUnk = NULL;
CoInitialize( NULL);
result = CoCreateInstanc e( CLSID_FtpProtoc ol,
NULL,
CLSCTX_INPROC_S ERVER,
IID_IInternetPr otocol,
(LPVOID*)&_pUnk );

If I use the following C# code, I receive an error. (OutOfMemoryExc eption)
Guid IID_IInternetPr otocolInfo = new
Guid("{79eac9e3-baf9-11ce-8c82-00aa004ba90b}") ;
objType = Type.GetTypeFro mCLSID(IID_IInt ernetProtocolIn fo);
Activator.Creat eInstance(objTy pe);

Any thoughts would be greatly appreciated.

Thanks,
Brian.



Nov 15 '05 #5
Hi Mattias,

Thank you for looking into the issue.

I was not aware there was a CoCreateInstanc e that you could invoke from C#.
I assume you are using some form of reflection to access the object and then
call P/Invoke?

My under the covers COM and C++ skills are seriously lacking. While I
understand the fundamentals and can do some of the advanced stuff, this is a
little further down the road.

In another project, I received an instance of an object through the
marshaller and then invoked methods by name. The problem I have here is
actually getting the initial instance.

Thanks,
B.
"Mattias Sjögren" <ma************ ********@mvps.o rg> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Brian,
If I use the following unmanaged C++ code, I can create an instance of thefilter.

HRESULT result;
LPUNKNOWN _pUnk = NULL;
CoInitialize ( NULL);
result = CoCreateInstanc e( CLSID_FtpProtoc ol,
NULL,
CLSCTX_INPROC_S ERVER,
IID_IInternetPr otocol,
(LPVOID*)&_pUnk );


If I replace IID_IInternetPr otocol with IID_IUnknown, I get an access
violation exception. Unless I'm missing something, that looks like a
bug. I suspect that's why you get the exception in managed code.

The only workaround I can suggest is that you call CoCreateInstanc e
through P/Invoke.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.

Nov 15 '05 #6
Hi Nicholas,

Yeah - was trying desperately not to have to do that. I love ATL and C++ -
NOT!!! :)

Hardcoding the handler in the PROTOCOLS key works perfectly for me and
initiates my C# handler. I have registered my protocol as test: for now.
It's the re-routing of the calls to the ftp protocol handler that is killing
me.

All I really need to do is create and instance of the handler and bind it to
the IInternetProtoc ol interfaces (or other pluggable protocol handlers) in
order to reverse engineer it. Then I implement all the interface methods and
pass the calls to the FTP handler instance. I can then examine all data in
transit.

I appreciate the help though.

Thanks,
B.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Brian,

It would be much easier to implement a pluggable protocol handler in
C++. You can create an ATL project that will do all of the COM plumbing for you. Once you have that, all you should have to worry about is the
implementation of the interface (along with the registration).

However, I don't know if you can register your own FTP handler. I think that for protocols like HTTP and FTP, the COM Moniker framework hard-codes
the protocol handlers.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Brian Rogers" <no**@none.co m> wrote in message
news:ed******** ******@TK2MSFTN GP09.phx.gbl...
Hi Nicholas,

I appreciate the feedback.

The objective is to place a wrapper around the protocol adapter, so I can
reverse engineer the data flow in both directions. I want to analyse the
data flow between IE and the FTP protocol handler.

I actually have no idea how the IMoniker interface comes into play. I
believe the handler was supposed to support the IInternetProtoc ol and
IInternetProtoc olRoot interfaces amongst others. Currently, I can't even
create the filter to bind it to IUnknown.

In the end, I want to create a custom FTP Protocol handler in C#. My C++ is
not good enough to create and expose an unmanaged factory class, so that

was
not an option for me.

Thanks,
B.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote

in
message news:uR******** ******@TK2MSFTN GP10.phx.gbl...
Brian,

If you are trying to access the asyncronous pluggable protocol

adaptor,
you shouldn't be creating it directly, but rather, you should be using the IMoniker interface.

However, that doesn't mean that one ^can't^ create it directly, as it should just be another COM object. It could be that there is something in
the constructor of the class that detects some sort of context (just a
guess).

As a workaround, you can have unmanaged code that creates the object, and then passes the pointer to managed code.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Brian Rogers" <no**@none.co m> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
> Hello everyone,
>
> I apologize for the cross and re-post, but I am still searching for

an > answer.
>
> Why can C++ can create this object, but C# can't?
>
> I am trying to create an instance of the default FTP asynchronous
pluggable
> protocol adaptor, so I can analyse the traffic between urlmon.dll

(IE) and
> the FTP server. The language I am attempting to use is C#.
>
> The CLSID for the adaptor (as referenced in the protocol registry
key) is
> {79eac9e3-baf9-11ce-8c82-00aa004ba90b} and is stored as

CLSID_FtpProtoc ol.
>
> If I use the following unmanaged C++ code, I can create an instance
of the
> filter.
>
> HRESULT result;
> LPUNKNOWN _pUnk = NULL;
> CoInitialize( NULL);
> result = CoCreateInstanc e( CLSID_FtpProtoc ol,
> NULL,
> CLSCTX_INPROC_S ERVER,
> IID_IInternetPr otocol,
> (LPVOID*)&_pUnk );
>
> If I use the following C# code, I receive an error.

(OutOfMemoryExc eption)
>
> Guid IID_IInternetPr otocolInfo = new
> Guid("{79eac9e3-baf9-11ce-8c82-00aa004ba90b}") ;
> objType = Type.GetTypeFro mCLSID(IID_IInt ernetProtocolIn fo);
> Activator.Creat eInstance(objTy pe);
>
> Any thoughts would be greatly appreciated.
>
> Thanks,
> Brian.
>
>
>
>



Nov 15 '05 #7
Brian,

In that case, I would stick with what I originally proposed, which is
getting the pointer in unmanaged code and then passing that back to managed
code.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Brian Rogers" <no**@none.co m> wrote in message
news:eP******** ******@TK2MSFTN GP12.phx.gbl...
Hi Nicholas,

Yeah - was trying desperately not to have to do that. I love ATL and C++ -
NOT!!! :)

Hardcoding the handler in the PROTOCOLS key works perfectly for me and
initiates my C# handler. I have registered my protocol as test: for now.
It's the re-routing of the calls to the ftp protocol handler that is killing me.

All I really need to do is create and instance of the handler and bind it to the IInternetProtoc ol interfaces (or other pluggable protocol handlers) in
order to reverse engineer it. Then I implement all the interface methods and pass the calls to the FTP handler instance. I can then examine all data in
transit.

I appreciate the help though.

Thanks,
B.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in message news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Brian,

It would be much easier to implement a pluggable protocol handler in
C++. You can create an ATL project that will do all of the COM plumbing for
you. Once you have that, all you should have to worry about is the
implementation of the interface (along with the registration).

However, I don't know if you can register your own FTP handler. I

think
that for protocols like HTTP and FTP, the COM Moniker framework hard-codes
the protocol handlers.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Brian Rogers" <no**@none.co m> wrote in message
news:ed******** ******@TK2MSFTN GP09.phx.gbl...
Hi Nicholas,

I appreciate the feedback.

The objective is to place a wrapper around the protocol adapter, so I can reverse engineer the data flow in both directions. I want to analyse the data flow between IE and the FTP protocol handler.

I actually have no idea how the IMoniker interface comes into play. I
believe the handler was supposed to support the IInternetProtoc ol and
IInternetProtoc olRoot interfaces amongst others. Currently, I can't even create the filter to bind it to IUnknown.

In the end, I want to create a custom FTP Protocol handler in C#. My C++ is
not good enough to create and expose an unmanaged factory class, so
that
was
not an option for me.

Thanks,
B.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om>
wrote in
message news:uR******** ******@TK2MSFTN GP10.phx.gbl...
> Brian,
>
> If you are trying to access the asyncronous pluggable protocol
adaptor,
> you shouldn't be creating it directly, but rather, you should be
using the
> IMoniker interface.
>
> However, that doesn't mean that one ^can't^ create it directly,
as it
> should just be another COM object. It could be that there is

something
in
> the constructor of the class that detects some sort of context (just

a > guess).
>
> As a workaround, you can have unmanaged code that creates the

object,
> and then passes the pointer to managed code.
>
> Hope this helps.
>
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - mv*@spam.guard. caspershouse.co m
>
>
> "Brian Rogers" <no**@none.co m> wrote in message
> news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
> > Hello everyone,
> >
> > I apologize for the cross and re-post, but I am still searching

for an > > answer.
> >
> > Why can C++ can create this object, but C# can't?
> >
> > I am trying to create an instance of the default FTP asynchronous
> pluggable
> > protocol adaptor, so I can analyse the traffic between urlmon.dll (IE) and
> > the FTP server. The language I am attempting to use is C#.
> >
> > The CLSID for the adaptor (as referenced in the protocol registry key) is
> > {79eac9e3-baf9-11ce-8c82-00aa004ba90b} and is stored as
CLSID_FtpProtoc ol.
> >
> > If I use the following unmanaged C++ code, I can create an
instance
of the
> > filter.
> >
> > HRESULT result;
> > LPUNKNOWN _pUnk = NULL;
> > CoInitialize( NULL);
> > result = CoCreateInstanc e( CLSID_FtpProtoc ol,
> > NULL,
> > CLSCTX_INPROC_S ERVER,
> > IID_IInternetPr otocol,
> > (LPVOID*)&_pUnk );
> >
> > If I use the following C# code, I receive an error.
(OutOfMemoryExc eption)
> >
> > Guid IID_IInternetPr otocolInfo = new
> > Guid("{79eac9e3-baf9-11ce-8c82-00aa004ba90b}") ;
> > objType = Type.GetTypeFro mCLSID(IID_IInt ernetProtocolIn fo);
> > Activator.Creat eInstance(objTy pe);
> >
> > Any thoughts would be greatly appreciated.
> >
> > Thanks,
> > Brian.
> >
> >
> >
> >
>
>



Nov 15 '05 #8
Brian,
I was not aware there was a CoCreateInstanc e that you could invoke from C#.
I assume you are using some form of reflection to access the object and then
call P/Invoke?


No reflection needed, just declare the function like this

[DllImport("ole3 2.dll", PreserveSig=fal se)]
[return: MarshalAs(Unman agedType.IUnkno wn)]
static extern object CoCreateInstanc e(
[MarshalAs(Unman agedType.LPStru ct)] Guid rclsid,
[MarshalAs(Unman agedType.IUnkno wn)] object pUnkOuter,
uint dwClsContext,
[MarshalAs(Unman agedType.LPStru ct)] Guid riid);

and call it something like this

Guid CLSID_FtpProtoc ol = new
Guid("79eac9e3-baf9-11ce-8c82-00aa004ba90b");
Guid IID_IInternetPr otocol = new
Guid("79eac9e4-baf9-11ce-8c82-00aa004ba90b");

o = CoCreateInstanc e( CLSID_FtpProtoc ol, null, 1
/*CLSCTX_INPROC_ SERVER*/, IID_IInternetPr otocol );

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #9
I will give it a shot,
Thanks.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Brian,

In that case, I would stick with what I originally proposed, which is
getting the pointer in unmanaged code and then passing that back to managed code.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Brian Rogers" <no**@none.co m> wrote in message
news:eP******** ******@TK2MSFTN GP12.phx.gbl...
Hi Nicholas,

Yeah - was trying desperately not to have to do that. I love ATL and C++ -
NOT!!! :)

Hardcoding the handler in the PROTOCOLS key works perfectly for me and
initiates my C# handler. I have registered my protocol as test: for now.
It's the re-routing of the calls to the ftp protocol handler that is killing
me.

All I really need to do is create and instance of the handler and bind it to
the IInternetProtoc ol interfaces (or other pluggable protocol handlers)
in order to reverse engineer it. Then I implement all the interface methods

and
pass the calls to the FTP handler instance. I can then examine all data in transit.

I appreciate the help though.

Thanks,
B.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote

in
message news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Brian,

It would be much easier to implement a pluggable protocol handler in C++. You can create an ATL project that will do all of the COM plumbing
for
you. Once you have that, all you should have to worry about is the
implementation of the interface (along with the registration).

However, I don't know if you can register your own FTP handler. I

think
that for protocols like HTTP and FTP, the COM Moniker framework hard-codes the protocol handlers.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Brian Rogers" <no**@none.co m> wrote in message
news:ed******** ******@TK2MSFTN GP09.phx.gbl...
> Hi Nicholas,
>
> I appreciate the feedback.
>
> The objective is to place a wrapper around the protocol adapter, so
I can
> reverse engineer the data flow in both directions. I want to analyse the > data flow between IE and the FTP protocol handler.
>
> I actually have no idea how the IMoniker interface comes into play.
I > believe the handler was supposed to support the IInternetProtoc ol and > IInternetProtoc olRoot interfaces amongst others. Currently, I can't

even > create the filter to bind it to IUnknown.
>
> In the end, I want to create a custom FTP Protocol handler in C#. My C++ is
> not good enough to create and expose an unmanaged factory class, so that was
> not an option for me.
>
> Thanks,
> B.
>
> "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
> message news:uR******** ******@TK2MSFTN GP10.phx.gbl...
> > Brian,
> >
> > If you are trying to access the asyncronous pluggable protocol
> adaptor,
> > you shouldn't be creating it directly, but rather, you should be using the
> > IMoniker interface.
> >
> > However, that doesn't mean that one ^can't^ create it directly, as
it
> > should just be another COM object. It could be that there is something
in
> > the constructor of the class that detects some sort of context
(just a > > guess).
> >
> > As a workaround, you can have unmanaged code that creates the
object,
> > and then passes the pointer to managed code.
> >
> > Hope this helps.
> >
> >
> > --
> > - Nicholas Paldino [.NET/C# MVP]
> > - mv*@spam.guard. caspershouse.co m
> >
> >
> > "Brian Rogers" <no**@none.co m> wrote in message
> > news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
> > > Hello everyone,
> > >
> > > I apologize for the cross and re-post, but I am still searching

for
an
> > > answer.
> > >
> > > Why can C++ can create this object, but C# can't?
> > >
> > > I am trying to create an instance of the default FTP

asynchronous > > pluggable
> > > protocol adaptor, so I can analyse the traffic between

urlmon.dll (IE)
> and
> > > the FTP server. The language I am attempting to use is C#.
> > >
> > > The CLSID for the adaptor (as referenced in the protocol
registry key)
> is
> > > {79eac9e3-baf9-11ce-8c82-00aa004ba90b} and is stored as
> CLSID_FtpProtoc ol.
> > >
> > > If I use the following unmanaged C++ code, I can create an

instance
of
> the
> > > filter.
> > >
> > > HRESULT result;
> > > LPUNKNOWN _pUnk = NULL;
> > > CoInitialize( NULL);
> > > result = CoCreateInstanc e( CLSID_FtpProtoc ol,
> > > NULL,
> > > CLSCTX_INPROC_S ERVER,
> > > IID_IInternetPr otocol,
> > > (LPVOID*)&_pUnk );
> > >
> > > If I use the following C# code, I receive an error.
> (OutOfMemoryExc eption)
> > >
> > > Guid IID_IInternetPr otocolInfo = new
> > > Guid("{79eac9e3-baf9-11ce-8c82-00aa004ba90b}") ;
> > > objType = Type.GetTypeFro mCLSID(IID_IInt ernetProtocolIn fo);
> > > Activator.Creat eInstance(objTy pe);
> > >
> > > Any thoughts would be greatly appreciated.
> > >
> > > Thanks,
> > > Brian.
> > >
> > >
> > >
> > >
> >
> >
>
>



Nov 15 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
28132
by: boxim | last post by:
Hi all, Real easy one I think, just can't find example, I need to create an instance of a type, but i don't have a type var, i have a string e.g. string t = "MyNamespace.Class1"; I wan't to do something like
2
2751
by: John Hughes | last post by:
Hi, Is it possible to create an object from a stored (database,xml or variable) name? For instance I have 2 class names stored in my database. Depending on the application settings I want to create an object based on the class name that I store in the database. Any ideas how to do this?
4
14464
by: Heliotic | last post by:
Hi everyone, Currently I am working on an application that will perform a remote scan of a specified server using the following code: Type t = Type.GetTypeFromProgID( "Microsoft.Update.Session", "proact" ); UpdateSession UpdSess = (UpdateSession) Activator.CreateInstance(t); This code works quite well, as long as the user you are currently authenticated to also has administrative access on the target device. This
7
2209
by: Dave Taylor | last post by:
I have a DataTable with three string columns, "Value", "Format" and "Type" However, some of the rows contain numbers and dates in the Value field. So I would like to be able to format the output based on the format specifier in the Format field. The problem is, since the Value field is a string, it doesnt properly "format". So I need to convert to an object of the type specified by "Type"...ok, so Activator.CreateInstance() BUT the...
2
3712
by: Nguyen Xuan Hoang | last post by:
In VB6, There is CallByName function, in .NET there are Activator.CreateInstance but it requires a Type instead of a string name of type. Function Activator.CreateInstance(Type) as Object There is also CreateInstance(AssemblyName as string,ObjectTypeName as string) but it returns ObjectHandle instead Object. Function Activator.CreateInstance(String,String) as HandleObject
6
2429
by: Rene Mansveld | last post by:
Hi, how can I create an instance (object) of a class (form) if I only know the classname (VB.NET 1.0)? I need to do this in a complex app where jobs consist of parts. Each part's data is saved in a separate database table. For the parts, the form's class name is saved in a data table, so that I know which form to use. As this is a string, I need to be able to create the form by it's name (like CreateObject() does for COM objects).
7
1650
by: Ronald S. Cook | last post by:
Thanks for reading this... Our current Win app employs a ListView control wherein the tag for an item is, for example, "ContentManager.DataModel.PowerPointContent". The following code exists (and works just fine) for when the user clicks on any item within the ListView: private void listView1_MouseClick( object sender, MouseEventArgs e ) { Type listItemType = (Type)( ( sender as ListView ).FocusedItem.Tag );
13
2419
by: docschnipp | last post by:
Hi, I have a bunch of object derived from the same base class. They all share the same constructor with some parameters. Now, instead of using a large switch() statement where I call every single Object by itself, I'd like to assign a reference to the class type and call it later without knowing the derived type. Example:
4
6073
by: =?Utf-8?B?QWRl?= | last post by:
Hi All, I want to create an instance of an object that implements a known interface. I just want to pass the assembly location and name followed by the class. My code looks like this: // The OK part IMyInterface MyInstance; System.RunTime.Remoting.ObjectHandle Oh =
0
8604
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8538
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8961
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8801
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6459
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4324
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2974
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1957
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.