Groups | Blog | Home
all groups > dotnet interop > june 2007 >

dotnet interop : Com Interop and Type.GetType


Mwob
6/5/2007 6:14:56 AM
Hi,

I am using the Microsoft Caching Block with the database as a backend
store, and all works fine under .NET. I am trying to get the same code
to work when my assembly is called via COM Interop from a VB6 client.
When this happens, the caching block falls over because a call to
Type.GetType has failed to load the required assembly. The Assembly is
fully qualified like this:

Microsoft.Practices.EnterpriseLibrary.Caching.Database.DataBackingStore,
Microsoft.Practices.EnterpriseLibrary.Caching.Database,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=null

The code looks like this:

Type providerType = Type.GetType(typeName, false);

[quoted text, click to view]
GetType is called, so in a normal app it would look in the "debug"
folder if running in debug, and probably the GAC too... But because
this is COM INterop, I don't understand where .NET is looking for the
assembly, and I'm not sure what I can do - perhaps force it to look
somewhere else perhaps?


Can anyone help me?



Matt.
Mattias Sjögren
6/5/2007 8:49:57 PM

[quoted text, click to view]

It will still look in the application directory, but in this case that
means the VB6 application directory (or the VB directory if you're
running from inside the IDE).

Fuslogvw.exe is a great little tool in the .NET SDK for finding the
cause of binding failures.


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Mwob
6/6/2007 12:52:31 AM
Thanks, I realised this soon after I posted. Unfourtuntely its not so
simple for me - rather than a VB Client exe calling through to
the .NET assembly, it will be a COM component which in turn will be
instantiated from an ASP page.

So, because it goes ASP -> COM -> .NET Assembly -> Caching block, the
caching block looks for the assembly in C:\windows\system32
(presumably because the ASP process (DLLHOST.EXE) is in that folder).

I'm completely stuck - I want to tell the Caching block to load the
assembly from a folder where I know it will be, not in system32. But I
don't know how to do this, or if its possible. I toyed with the idea
of adding the caching block to the GAC, but its heavily bound to the
rest of the enterprise block so even this isn't easy to do.

Any ideas?

On 5 Jun, 19:49, Mattias Sj=F6gren <mattias.dont.want.s...@mvps.org>
[quoted text, click to view]

AddThis Social Bookmark Button